Skip to content

Fix undefined commit hash in deployment detail view - #7276

Merged
mohammedfirdouss merged 1 commit into
pipe-cd:masterfrom
vikash7485:fix/guard-undefined-commit-hash
Sep 1, 2026
Merged

Fix undefined commit hash in deployment detail view#7276
mohammedfirdouss merged 1 commit into
pipe-cd:masterfrom
vikash7485:fix/guard-undefined-commit-hash

Conversation

@vikash7485

Copy link
Copy Markdown
Contributor

What this PR does:

Guard against undefined or null deployment.trigger.commit.hash in the DeploymentDetail component (web/src/components/deployments-detail-page/deployment-detail/index.tsx). When hash is 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 a hash field (e.g. from an incomplete gRPC response or synthetic test payload), it throws an unhandled TypeError: 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.

  • How are users affected by this change: Users will no longer encounter a blank screen / runtime crash when viewing deployments that have missing commit hash values.
  • Is this breaking change: No.
  • How to migrate (if breaking change): N/A.

Copilot AI lite review requested due to automatic review settings August 29, 2026 09:11
@vikash7485
vikash7485 requested review from a team as code owners August 29, 2026 09:11
@netlify

netlify Bot commented Aug 29, 2026

Copy link
Copy Markdown

Deploy Preview for pipecd-site canceled.

Name Link
🔨 Latest commit e5e7eb1
🔍 Latest deploy log https://app.netlify.com/projects/pipecd-site/deploys/6a95d1d250981e00086e46d6

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.hash before slicing to avoid TypeError crashes.
  • Add a unit test that verifies DeploymentDetail renders when the commit hash is undefined.

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.

@vikash7485
vikash7485 force-pushed the fix/guard-undefined-commit-hash branch 2 times, most recently from d4375d9 to 2467861 Compare August 29, 2026 09:29
@vikash7485
vikash7485 requested a lite review from Copilot August 31, 2026 18:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread web/src/components/deployments-detail-page/deployment-detail/index.test.tsx Outdated
@vikash7485
vikash7485 force-pushed the fix/guard-undefined-commit-hash branch from 2467861 to 64dbf12 Compare August 31, 2026 19:09
…on test

Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
@vikash7485
vikash7485 force-pushed the fix/guard-undefined-commit-hash branch from 64dbf12 to e5e7eb1 Compare August 31, 2026 19:11
@vikash7485
vikash7485 requested a lite review from Copilot August 31, 2026 19:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.commit is an optional field (commit?: Commit.AsObject), so spreading ...dummyTrigger.commit will fail type-checking because the spread operand may be undefined. Narrow or assert the type before spreading.
          ...dummyTrigger.commit,

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@mohammedfirdouss
mohammedfirdouss merged commit e965eab into pipe-cd:master Sep 1, 2026
64 checks passed
@mohammedfirdouss

Copy link
Copy Markdown
Contributor

Thank you for the contributions @vikash7485

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Thank you for contributing to PipeCD, @vikash7485! The changes in this pull request will be part of the upcoming release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants