| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
…tate status --json emitted zero bytes of stdout when logged out or unlinked. Every state now produces a JSON object with loggedIn/linked booleans and a stable error code (NOT_LOGGED_IN, NOT_LINKED) plus suggested fix. Success payload gains additive loggedIn/linked/error fields.
📝 Walkthrough
Summary by CodeRabbit
WalkthroughThe status command now exports standardized JSON error codes and returns structured envelopes for unauthenticated, expired-session, unlinked, and successful states. A new Vitest suite mocks command helpers and validates JSON output, exit behavior, human-readable output, account and team data, site data, and expired-session handling. Estimated code review effort: 3 (Moderate) | ~20 minutes Suggested reviewers: aitchiss 🚥 Pre-merge checks | ✅ 5 ✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. ❤️ ShareComment @coderabbitai help to get the list of available commands. |
Sorry, something went wrong.
📊 Benchmark resultsComparing with c97eb90
|
Sorry, something went wrong.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agentsVerify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. Inline comments: In `@tests/unit/commands/status/status.test.ts`: - Around line 170-178: The test for the JSON expired-session response should validate the complete standardized envelope rather than a partial match. Update the assertion in the “with --json emits a NOT_LOGGED_IN error envelope before throwing” test to check linked, account, siteData, and error.fix along with the existing loggedIn and error.code fields, using the expected contract values.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a4f92090-2664-404d-bd9b-37424d291b79
📥 CommitsReviewing files that changed from the base of the PR and between c97eb90 and 9666dfc.
📒 Files selected for processing (2)CodeRabbit considers these linked repositories for cross-repo context during reviews:
Sorry, something went wrong.
| test('with --json emits a NOT_LOGGED_IN error envelope before throwing', async () => { | ||
| await expect(status({ json: true }, createMockCommand())).rejects.toThrow('Your session has expired') | ||
|
|
||
| expect(jsonMessages).toHaveLength(1) | ||
| expect(jsonMessages[0]).toMatchObject({ | ||
| loggedIn: false, | ||
| error: { code: STATUS_ERROR_CODES.NOT_LOGGED_IN }, | ||
| }) | ||
| }) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Assert the complete expired-session envelope.
toMatchObject permits regressions to linked, account, siteData, and error.fix, despite those being part of the standardized response contract.
Proposed fix- expect(jsonMessages[0]).toMatchObject({
+ expect(jsonMessages[0]).toEqual({
loggedIn: false,
- error: { code: STATUS_ERROR_CODES.NOT_LOGGED_IN },
+ linked: false,
+ account: null,
+ siteData: null,
+ error: {
+ code: STATUS_ERROR_CODES.NOT_LOGGED_IN,
+ fix: 'netlify login or NETLIFY_AUTH_TOKEN',
+ },
})‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| test('with --json emits a NOT_LOGGED_IN error envelope before throwing', async () => { | |
| await expect(status({ json: true }, createMockCommand())).rejects.toThrow('Your session has expired') | |
| expect(jsonMessages).toHaveLength(1) | |
| expect(jsonMessages[0]).toMatchObject({ | |
| loggedIn: false, | |
| error: { code: STATUS_ERROR_CODES.NOT_LOGGED_IN }, | |
| }) | |
| }) | |
| test('with --json emits a NOT_LOGGED_IN error envelope before throwing', async () => { | |
| await expect(status({ json: true }, createMockCommand())).rejects.toThrow('Your session has expired') | |
| expect(jsonMessages).toHaveLength(1) | |
| expect(jsonMessages[0]).toEqual({ | |
| loggedIn: false, | |
| linked: false, | |
| account: null, | |
| siteData: null, | |
| error: { | |
| code: STATUS_ERROR_CODES.NOT_LOGGED_IN, | |
| fix: 'netlify login or NETLIFY_AUTH_TOKEN', | |
| }, | |
| }) | |
| }) |
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/commands/status/status.test.ts` around lines 170 - 178, The test for the JSON expired-session response should validate the complete standardized envelope rather than a partial match. Update the assertion in the “with --json emits a NOT_LOGGED_IN error envelope before throwing” test to check linked, account, siteData, and error.fix along with the existing loggedIn and error.code fields, using the expected contract values.
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Split from #8300 (7 of 9).
What
netlify status --json emitted zero bytes of stdout when logged out or unlinked (exit 1 with no explanation of which). Now every state emits a JSON object:
{ "loggedIn": true, "linked": false, "account": { "Name": "…", "Email": "…" }, "siteData": null, "error": { "code": "NOT_LINKED", "fix": "netlify link" } }Codes: NOT_LOGGED_IN (no token or expired session), NOT_LINKED. The success payload gains additive loggedIn/linked/error: null fields. Non-JSON output and exit semantics are unchanged.
Why it helps agents
status --json is the first command an agent runs to orient itself. Zero-byte stdout forces guessing between "not logged in" and "not linked"; a stable error.code + fix makes recovery a single deterministic step, and JSON.parse(stdout) never throws.
Testing