Skip to content

fix: explain an invalid --repo instead of saying Prismic can't be reached - #488

Open
lihbr wants to merge 2 commits into
mainfrom
lh/repository-domain-check
Open

lihbr wants to merge 2 commits into
mainfrom
lh/repository-domain-check

Conversation

@lihbr

@lihbr lihbr commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

An agent passed a list of 31 repository names to --repo. The CLI used the whole list as one name, so:

  • it said "Can't reach Prismic", because the list made a broken web address
  • it sent the list to analytics as the repository
  • commands that send the repository in a header crashed with "The CLI reached a bug"

Now the CLI first checks that the value can be the my-repo in my-repo.prismic.io. If it can't, the command says Check your repository domain: "…". Pass one repository domain per command, such as "my-repo". Analytics leave it out of repository, but the value still shows in the command and the error. The backend still decides whether the repository exists.

Command Before After
token create -r <31 names> "Can't reach Prismic", list sent to analytics Clear error, no repository in analytics
token create -r <3 short names> Request sent to a wrong host, "Repository not found" Clear error, no request
repo view -r "a\nb" (header) "The CLI reached a bug" Clear error, no request
type list -r "a\nb" (no --repo option) "Unknown option", list sent to analytics Same error, no repository in analytics
repo view -r my-repo Works Works, unchanged

Proof: reproduced with the built CLI, with analytics captured locally. After the fix, a multi-line --repo gets the new error and analytics get no repository. A valid name works as before. New e2e tests cover both cases and pass in CI.

Reviewed with sol-loop: 2 rounds with Claude Opus 5.5 in place of Sol. Verdict: approved.

Created with Claude Opus 5.5 in Claude Code.


Note

Low Risk
Input validation and clearer errors around existing repo handling; valid single-domain --repo behavior stays the same.

Overview
Invalid --repo values (e.g. newline-separated lists) now fail fast with Check your repository domain: … Pass one repository domain per command instead of misleading "Can't reach Prismic", header crashes, or bogus analytics.

The CLI adds isSubdomain in url.ts and routes repository URLs/headers through getRepositoryDomain / getRepositoryHeaders, which throw InvalidRepositoryDomainError when the value isn’t a single DNS label. index.ts only sends repository to analytics when --repo passes that check. E2E tests cover invalid --repo on pull and token create.

Reviewed by Cursor Bugbot for commit f3660c1. Bugbot is set up for automated code reviews on this repo. Configure here.

lihbr and others added 2 commits November 16, 2026 15:12
…ched

A multi-line --repo value was glued into one hostname, so DNS failed and
the CLI said "Can't reach Prismic". The value also went to analytics as
the repository. Check that the repository is a valid subdomain before
putting it in a URL or header, and keep invalid values out of analytics
and Sentry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant