Skip to content

fix(env): JSON error envelope + non-zero exit when unlinked; honor --site#8334

Open
DavidWells wants to merge 1 commit into
mainfrom
split/env-json-errors
Open

fix(env): JSON error envelope + non-zero exit when unlinked; honor --site#8334
DavidWells wants to merge 1 commit into
mainfrom
split/env-json-errors

Conversation

@DavidWells

Copy link
Copy Markdown
Contributor

Split from #8300 (6 of 9).

What

netlify env:get DATABASE_URL --json in an unlinked directory used to emit zero bytes with exit 0. Now it exits 1 with:

{
  "error": {
    "code": "NOT_LINKED",
    "message": "No project id found, please run inside a project folder or `netlify link`",
    "fix": "netlify link"
  }
}

Applies to env:get/list/set/unset/import and env:clone (custom --from message). Non-JSON invocations write the message to stderr and exit 1. Also: the documented-but-ignored --site flag now actually resolves the target project.

Why it helps agents

Empty stdout + exit 0 is how empty secrets end up in configs — a consumer can't tell "variable is empty" from "you're not linked." A stable error.code plus a fix field lets an agent branch and self-correct instead of guessing from silence.

Testing

  • New unit tests for the envelope and --site resolution; env integration tests updated (env:clone now asserts exit 1 + message)
  • typecheck ✓ lint ✓ unit suite ✓ env integration suite (64 tests) ✓

…site

env:get/list/set/unset/import in an unlinked folder emitted nothing and
exited 0 - with --json that is indistinguishable from an empty value.
Failures now emit {"error":{code,message,fix}} on stdout with --json,
write the message to stderr otherwise, and exit 1. The documented
--site flag was silently ignored; it now resolves the target site.
@DavidWells DavidWells requested a review from a team as a code owner July 6, 2026 17:59
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@DavidWells, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 49 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c5b5e4f5-dd64-4da9-8748-1cb2e188c02d

📥 Commits

Reviewing files that changed from the base of the PR and between 3c41e72 and 4453208.

⛔ Files ignored due to path filters (1)
  • tests/integration/commands/env/__snapshots__/env.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (10)
  • src/commands/env/env-clone.ts
  • src/commands/env/env-get.ts
  • src/commands/env/env-import.ts
  • src/commands/env/env-list.ts
  • src/commands/env/env-set.ts
  • src/commands/env/env-unset.ts
  • src/commands/env/utils.ts
  • tests/integration/commands/env/env.test.ts
  • tests/unit/commands/env/env-get.test.ts
  • tests/unit/commands/env/utils.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch split/env-json-errors

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown

📊 Benchmark results

Comparing with 3c41e72

  • Dependency count: 1,127 (no change)
  • Package size: 379 MB ⬇️ 0.00% decrease vs. 3c41e72
  • Number of ts-expect-error directives: 359 (no change)

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