fix(knative): guard optional spec property access in service and domain claim lists - #1074
Open
vikash7485 wants to merge 1 commit into
Open
vikash7485 wants to merge 1 commit into
vikash7485 wants to merge 1 commit into
Conversation
vikash7485
requested review from
ashu8912,
illume,
joaquimrocha,
skoeva,
sniok,
vyncent-t and
yolossn
as code owners
August 8, 2026 14:27
vikash7485
force-pushed
the
fix/knative-spec-optional-chaining
branch
from
August 8, 2026 14:30
96ace82 to
02d3657
Compare
illume
requested changes
Sep 29, 2026
illume
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution.
Could you take a look at the commit messages in this PR? We follow a Linux kernel style for git commits — see the contributing guide and git log for examples.
Commits that need attention
fix(knative): guard optional spec property access in service and domain claim lists— Missingarea: descriptionprefix — e.g.frontend: HomeButton: Fix so it navigates to homeorbackend: config: Add enable-dynamic-clusters flag.
Commit guidelines
- Use atomic commits focused on a single change.
- Use the title format
<area>: <Description of changes>— description must start with a capital letter. - Keep the title under 72 characters (soft requirement).
- Explain the intention and why the change is needed.
- Make commit titles meaningful and describe what changed.
- Do not add code that a later commit rewrites; squash or reorder commits instead.
- Do not include
Fixes #NNin commit messages.
Good examples:
frontend: HomeButton: Fix so it navigates to homebackend: config: Add enable-dynamic-clusters flag
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused null-safety changes correctly address both documented crash paths without introducing regressions.
Review effort: Balanced
Findings: None
What changed in this PR
Prevents Knative list views from crashing on partially initialized resources.
Changes:
- Safely reads optional DomainMapping references.
- Safely reads ClusterDomainClaim namespaces.
| File | Description |
|---|---|
knative/src/components/kservices/List.tsx |
Guards optional DomainMapping fields. |
knative/src/components/clusterdomainclaims/List.tsx |
Guards the namespace accessor. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…aim lists Safely access optional spec and spec.ref fields in KServices and ClusterDomainClaims list views to prevent runtime TypeErrors. Signed-off-by: vikash7485 <vikkiraj073@gmail.com>
vikash7485
force-pushed
the
fix/knative-spec-optional-chaining
branch
from
September 30, 2026 16:55
02d3657 to
667e710
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes potential runtime
TypeErrorcrashes in the Knative plugin (@headlamp-k8s/knative) when rendering custom resource lists where.specor nested.spec.reffields are omitted or initializing.Problem
KServicesList(plugins/knative/src/components/kservices/List.tsx):In
domainByServiceKey, the loop accessesdm.spec.ref.nameanddm.spec.ref.namespacedirectly without optional chaining onspecorref. When aDomainMappingresource is in a syncing or partial state (missing.specor.spec.ref), rendering the KServices list throwsTypeError: Cannot read properties of undefined (reading 'name'), causing the entire view to crash.ClusterDomainClaimsList(plugins/knative/src/components/clusterdomainclaims/List.tsx):The
namespacecolumngetValueaccessor readscdc.spec.namespacewithout optional chaining, whereas the cell renderer correctly guards withcdc.spec?.namespace. If aClusterDomainClaimpayload lacks aspecfield, table sorting/filtering crashes withTypeError: Cannot read properties of undefined (reading 'namespace').Solution
dm.spec?.ref?.nameanddm.spec?.ref?.namespace) inKServicesList.cdc.spec?.namespace || '') inClusterDomainClaimsListcolumn accessor.How Has This Been Tested?
npx tsc --noEmit(0 errors).npx eslint).npx vitest run).