Skip to content

fix(web): guard undefined hash in commit detail view - #7148

Open
vikash7485 wants to merge 1 commit into
pipe-cd:masterfrom
vikash7485:fix/guard-undefined-commit-hash
Open

fix(web): guard undefined hash in commit detail view#7148
vikash7485 wants to merge 1 commit into
pipe-cd:masterfrom
vikash7485:fix/guard-undefined-commit-hash

Conversation

@vikash7485

Copy link
Copy Markdown

What this PR does:

Guard against undefined hash in the deployment detail commit section by adding a null-coalescing fallback (?? "") before calling .slice(0, 7).

Why we need it:

When deployment.trigger.commit.hash is undefined (possible from older Piped v0 protobuf messages where the field was unpopulated), the current code calls .slice(0, 7) directly on undefined, causing a runtime crash:

TypeError: Cannot read properties of undefined (reading 'slice')

The outer guard at L254 (deployment.trigger?.commit &&) only checks that commit exists, not that hash is populated. This fix adds a safe fallback so the link renders with an empty string instead of crashing.

Which issue(s) this PR fixes:

Fixes #

Does this PR introduce a user-facing change?:

No. This prevents a crash for an edge case. Users with valid commit hashes see no difference.

  • How are users affected by this change: Deployments with missing commit hashes no longer crash the detail page.
    • Is this breaking change: No.
    • How to migrate (if breaking change): N/A.

When hash is undefined (e.g. from older Piped v0 messages where the
field was unpopulated), hash.slice(0, 7) throws:
TypeError: Cannot read properties of undefined (reading 'slice')

Add null-coalescing fallback to empty string before slicing.

Related: pipe-cd#6706
Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
@vikash7485
vikash7485 force-pushed the fix/guard-undefined-commit-hash branch from 9fc67c1 to 818473d Compare August 11, 2026 04:02
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.

1 participant