Skip to content

fix: affitor status and test run with an API key and no project config (QA-33) - #36

Merged
sonpiaz merged 6 commits into
mainfrom
fix/qa-33-status-test-with-key
Oct 13, 2026
Merged

sonpiaz merged 6 commits into
mainfrom
fix/qa-33-status-test-with-key

Conversation

@sonpiaz

@sonpiaz sonpiaz commented Oct 13, 2026

Copy link
Copy Markdown
Member

What

affitor status and affitor test read the project config through a new readConfigOrKeyOnly(flags): when the directory has no .affitor/config.json but a key was passed with --api-key or AFFITOR_API_KEY, they run without it. The API already resolves the program from the key (authenticateRequest → findProgramByApiToken); program_id in the query/body was never used. status prints the domain the API returns instead of config.domain. With neither config nor key, the error now says "Run npx affitor init to set up a new program, or set AFFITOR_API_KEY to use an existing one."

Why (QA-33)

Measured 13/10 with the test program's key on prod:

  • affitor@0.4.2 status in a directory without config → ✗ No Affitor config found … Run npx affitor init. init needs affitor login and creates a new program, so a brand whose program was made in the dashboard had no way to use status/test.
  • With a hand-written {version, program_id} config, status worked but printed undefined for the domain and t.undefined in the DNS hint.
  • This branch, built locally, in an empty directory with only AFFITOR_API_KEY: status 200 for program 1189, domain example.com (.internal/qa/2026-10-12/raw/qa33-cli-key-only-prod.txt).

Separate, not in this PR: affitor login offers only "Sign in with Google", so a brand that signed up with email + password cannot log in to the CLI (auth decision, reported to the manager).

Test

tests/status-test-key-only.test.ts (3 cases, committed first, 3 red on main): status with AFFITOR_API_KEY and no config calls /api/v1/cli/status with that key and prints the API domain, no "undefined"; test with --api-key and no config posts the event; with neither, the message names AFFITOR_API_KEY.

  • vitest run: 14 files, 118 tests pass. tsc --noEmit 0 errors. npm run build ok.

🤖 Generated with Claude Code

sonpiaz and others added 6 commits October 13, 2026 01:38
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A program created in the dashboard has a key but no .affitor/config.json; only init writes
one, and init creates a new program. The API finds the program from the key alone, so
status and test now run with --api-key or AFFITOR_API_KEY when there is no config, and
status shows the domain the API returns (it printed config.domain, 'undefined' without it).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…the DNS hint

The API returns the website minus its scheme with the path kept, so a site like
https://example.com/pricing/ made the hint t.example.com/pricing/. The config's domain is
used whenever there is a config (as before); key-only runs reduce the API website to its
hostname, and print no DNS hint when there is none.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@sonpiaz
sonpiaz merged commit 0e3bd67 into main Oct 13, 2026
1 check passed
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