feat(environments): add deploy by version - #3014
TheoGrandin74 wants to merge 9 commits into
Conversation
|
View your CI Pipeline Execution ↗ for commit be4f928
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗ ☁️ Nx Cloud last updated this comment at |
There was a problem hiding this comment.
All reported issues were addressed across 14 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## staging #3014 +/- ##
===========================================
- Coverage 51.69% 50.99% -0.70%
===========================================
Files 1356 1365 +9
Lines 29414 29884 +470
Branches 8706 8866 +160
===========================================
+ Hits 15205 15240 +35
- Misses 11716 12160 +444
+ Partials 2493 2484 -9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
There was a problem hiding this comment.
@cubic-dev Can you double check this path. When clicking the button we're redirected to an unknown page.
Screen.Recording.2026-09-25.at.11.17.01.mov
There was a problem hiding this comment.
@rmnbrd You're right to flag it — this looks like a real navigation bug, and it's a classic TanStack Router mismatch.
The notifyOnSuccess callback does:
navigate({
to: ENVIRONMENT_LOGS_URL(organizationId, projectId, environmentId),
})ENVIRONMENT_LOGS_URL(...) returns a fully-resolved URL string with the real IDs baked into it (something like /organization/<org>/project/<proj>/environment/<env>/logs). TanStack Router's navigate({ to }) expects a route path template (with $param placeholders that it matches against the registered route tree), not a fully-built path. When you hand it literal IDs, the path doesn't match the $organizationId/.../$environmentId route, so it falls through to the not-found page — hence the "unknown page."
The fix is to navigate against the route template and pass the params separately:
navigate({
to: '/organization/$organizationId/project/$projectId/environment/$environmentId/logs',
params: { organizationId, projectId, environmentId },
})If the logs route lives at a slightly different path (e.g. under a service or an overview tab), use the exact template from apps/console/src/routes/ rather than guessing.
Two honest caveats:
- This
navigatecall is pre-existing — this PR only changed the toast title and added the Terraform invalidation loop — but the new deploy-by-version flow surfaces that same broken toast action, so it's worth fixing here. Confirm the exact route path from the routes directory before patching. - I can't see the
ENVIRONMENT_LOGS_URLimplementation in the provided context, so I'm inferring it returns a full URL. If instead it returns a template, the mismatch would be elsewhere. Either way, navigating via the typed route withparamsis the correct approach.
Tip: get faster answers by chatting with cubic’s review copilot in the review UI
There was a problem hiding this comment.
@rmnbrd I have started the AI code review. It will take a few minutes to complete.
There was a problem hiding this comment.
@rmnbrd Fix with cubic is available during trial and on the Pro plan. Upgrade your plan to use this feature. https://www.cubic.dev/settings?tab=subscription
There was a problem hiding this comment.
All reported issues were addressed across 15 files
Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.
Re-trigger cubic
There was a problem hiding this comment.
1 issue found across 15 files (changes from recent commits).
Confidence score: 3/5
- In
getLatestEnvironmentDeploymentId, lagging history can override the mutation response and send “See pipeline” to the previous deployment; prefer the normalized mutation response ID when available.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="libs/domains/environments/feature/src/lib/hooks/get-latest-environment-deployment-id.ts">
<violation number="1" location="libs/domains/environments/feature/src/lib/hooks/get-latest-environment-deployment-id.ts:29">
P1: `getLatestEnvironmentDeploymentId` discards the mutation response whenever history returns a latest row, so a lagging history list can send “See pipeline” to the previous deployment. Prefer a normalized response ID when available, and query history only for VersionedId responses or missing IDs.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Re-trigger cubic
| if (latestDeploymentId) return normalizeEnvironmentDeploymentId(latestDeploymentId) | ||
| } catch { | ||
| // Use the mutation response if deployment history is temporarily unavailable. | ||
| } | ||
|
|
||
| return normalizeEnvironmentDeploymentId(deploymentId) | ||
| } |
There was a problem hiding this comment.
P1: getLatestEnvironmentDeploymentId discards the mutation response whenever history returns a latest row, so a lagging history list can send “See pipeline” to the previous deployment. Prefer a normalized response ID when available, and query history only for VersionedId responses or missing IDs.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At libs/domains/environments/feature/src/lib/hooks/get-latest-environment-deployment-id.ts, line 29:
<comment>`getLatestEnvironmentDeploymentId` discards the mutation response whenever history returns a latest row, so a lagging history list can send “See pipeline” to the previous deployment. Prefer a normalized response ID when available, and query history only for VersionedId responses or missing IDs.</comment>
<file context>
@@ -0,0 +1,35 @@
+ (a, b) => new Date(b.auditing_data.created_at).getTime() - new Date(a.auditing_data.created_at).getTime()
+ )[0]?.identifier.execution_id
+
+ if (latestDeploymentId) return normalizeEnvironmentDeploymentId(latestDeploymentId)
+ } catch {
+ // Use the mutation response if deployment history is temporarily unavailable.
</file context>
| deploymentId?: string | null | ||
| ) { | ||
| try { | ||
| const deployments = await queryClient.fetchQuery({ |
There was a problem hiding this comment.
The helper fetches deployment history and returns its newest ID even when the mutation supplied a valid execution ID. If another deployment starts before the user clicks “See pipeline,” the link can open that other deployment instead of the one that triggered the notification. Use the supplied ID when it is usable, and look up history when the mutation returned an environment VersionedId or no usable ID.
There was a problem hiding this comment.
Also, as the action is async, maybe it'd be worth to add a loading state to the toast's action button?
It feels odd to click on something and have the redirection a second after
Summary
Deploy by version
latestcontainer tags.Environment deployment navigation and recovery
VersionedId(...)as a route ID; when the response is aVersionedId, it retries fresh history briefly and shows a warning if no usable ID is available.Validation
git diff --checkpassed. Automated tests were not rerun.