fix: prevent infinite API loop on invalid environment URLs#7284
fix: prevent infinite API loop on invalid environment URLs#7284talissoncosta wants to merge 2 commits intomainfrom
Conversation
Closes #7283 Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.
Once credits are available, reopen this pull request to trigger a review.
Docker builds report
|
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
|
Visual Regression16 screenshots compared. See report for details. |
Drop the separate env-list fetch and verify project scope directly from the single-env query's `project` field. Also make the polling interval reactive to `is_creating`, removing the `pollingDone` / `trackedEnvId` state and the effect that managed it. Treat `isError` as not-found, covering permission-revoked and deleted-env cases. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
I have added information todocs/if required so people know about the feature.Changes
Closes #7283
When the URL contained an environment key that didn't belong to the current project (deleted env, typo, env from another project, stale bookmark, or permission revoked mid-session), the app entered an infinite API request loop and showed a sidebar loader that never resolved. Further requests appeared with the literal string
undefinedin the path.Root cause
Two bugs compounded:
EnvironmentReadyCheckerpolled every 1s with no error off-ramp. It only stopped polling on a successful response withis_creating: false— on a 4xx it kept polling forever.api_keyregardless of project scope, so a valid env key belonging to a different project returns200 OKand the checker falls through to render the page. Downstream components then fire queries with missing or stale env context — some usingenv?.api_keyin URL templates without a fallback, producing/api/v1/environments/undefined/...URLs.Sibling sidebar components (
EnvironmentAside,EnvironmentNavbar) conflated "env list loading" with "env missing from list" and showed loaders forever.Fix
EnvironmentReadyChecker: source of truth is now the project's env list (useGetEnvironmentsQuery). If the URL env isn't in the list, render an "Environment not found" state. The single-env poll is kept for theis_creatinghappy path but now skips once polling is complete or the env is known missing.useEffect) when the env ID changes, so recovering via URL change is instant and doesn't flash stale children.LoadingState,CreatingState,NotFoundStatecomponents; render flow is now guard clauses instead of nested ternaries./environment/createsentinel so the new-env form isn't caught.EnvironmentAside: hides the whole sidebar when the env isn't in the project list.EnvironmentNavbar:skip: !environmenton the change-request queries (no moreundefinedURL fetches); returnsnullwhen env isn't in the list.`${projectId}`template coerces in the two files touched (fixes pre-existingstring not assignable to numberTS errors).How did you test this code?
Manual verification on local dev server (
ENV=local npm run dev):/project/<id>/environment/<invalid-key>/features→ shows "Environment not found" in the main area, sidebar hidden, no repeat requests in Network tab./project/<id>/environment/<valid-key>/features→ loads features normally./project/<id>/environment/create→ create form renders (sentinel preserved)./environments/undefined/...URLs fire in any of the above flows.