Fix undefined commit hash in deployment detail view - #7276
Conversation
✅ Deploy Preview for pipecd-site canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR prevents a runtime crash in the web UI’s deployment detail page by safely handling cases where deployment.trigger.commit.hash is missing, ensuring the component can render even with incomplete deployment payloads.
Changes:
- Guard
deployment.trigger.commit.hashbefore slicing to avoidTypeErrorcrashes. - Add a unit test that verifies
DeploymentDetailrenders when the commit hash isundefined.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| web/src/components/deployments-detail-page/deployment-detail/index.tsx | Uses a safe fallback ("") before slicing the commit hash to prevent crashes. |
| web/src/components/deployments-detail-page/deployment-detail/index.test.tsx | Adds coverage for rendering when the commit hash is undefined. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
d4375d9 to
2467861
Compare
2467861 to
64dbf12
Compare
…on test Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
64dbf12 to
e5e7eb1
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
web/src/components/deployments-detail-page/deployment-detail/index.test.tsx:48
DeploymentTrigger.AsObject.commitis an optional field (commit?: Commit.AsObject), so spreading...dummyTrigger.commitwill fail type-checking because the spread operand may beundefined. Narrow or assert the type before spreading.
...dummyTrigger.commit,
|
Thank you for the contributions @vikash7485 |
|
Thank you for contributing to PipeCD, @vikash7485! The changes in this pull request will be part of the upcoming release! |
What this PR does:
Guard against undefined or null
deployment.trigger.commit.hashin theDeploymentDetailcomponent (web/src/components/deployments-detail-page/deployment-detail/index.tsx). Whenhashis missing, use a safe fallback""instead of directly calling.slice(0, 7).Why we need it:
In
DeploymentDetail, the commit hash was directly sliced (deployment.trigger.commit.hash.slice(0, 7)). If a deployment contains a trigger commit object without ahashfield (e.g. from an incomplete gRPC response or synthetic test payload), it throws an unhandledTypeError: Cannot read properties of undefined (reading 'slice')and crashes the entire component rendering.Does this PR introduce a user-facing change?:
Yes. Fixes a potential UI crash on the deployment detail page.