Repository navigation
fix(backend): validate non-nil VerbType in changeset and assign VerbUnknown fallback in autoscaler and oss k8s - #1059
Merged
Conversation
…nknown fallback in autoscaler and oss k8s
kyasbal
requested review from
RyuSA,
jyane,
kkuchima and
renamoo
as code owners
September 29, 2026 05:12
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces nil checks for VerbType and StateType in TimelineChangeSet.Flush to prevent potential nil pointer dereferences, returning descriptive errors if either is nil. To support this, various mappers and extractors (such as GKE Autoscaler mapper and OSS K8s extractor) have been updated to explicitly set fallback values like VerbUnknown when these fields are not populated. Additionally, corresponding unit tests have been updated and expanded to cover these new validation rules and default behaviors. There are no review comments provided, so I have no feedback to evaluate.
kyasbal
enabled auto-merge
September 29, 2026 05:16
Merged
via the queue into
GoogleCloudPlatform:main
with commit Sep 29, 2026
a50583b
17 checks passed
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.
Background & Problem
In the KHI frontend, hovering over certain timeline revisions could crash the UI with
Error: Verb ID 0 not foundfromTimelineStore._getRevisionVerb.This runtime crash occurred because some backend inspection tasks generated
StagingRevisionobjects without specifying aVerbType(leaving itnil), and the serialization layer inpkg/model/khifile/v6/changeset.go(flushRevision) lacked validation for nilVerbTypeandStateType. Consequently, unassigned verbs either defaulted to protobuf ID 0 or remained unmapped, causing frontend dictionary lookups to fail.Two backend components were identified producing revisions without a verb:
pkg/task/inspection/googlecloud/gkeautoscaler/impl/mapper.go):mapResultInfocreatedStagingRevisionfor cluster autoscaler timeline entries without settingVerbType.pkg/task/inspection/oss/k8s/extractor.go):ExtractOSSK8sAuditLogreturned an emptyK8sAuditLogFieldSetwhen neitherauditIDnorobjectRefwas present, leavingVerbunassigned.Solution Approach
Updated
flushRevisioninpkg/model/khifile/v6/changeset.goto explicitly return an error ifr.VerbType == nilorr.StateType == nil, identifying the affected path ID and failing fast rather than emitting invalid revisions.Updated
mapResultInfoinpkg/task/inspection/googlecloud/gkeautoscaler/impl/mapper.goto explicitly setVerbType: inspectioncore.VerbUnknownon the autoscaler timelineStagingRevision.Updated
ExtractOSSK8sAuditLoginpkg/task/inspection/oss/k8s/extractor.goto assignVerb: k8saudit.VerbUnknownon the fallback return whenauditIDandobjectRefare absent.Added unit tests in
changeset_test.goto verify error behavior whenVerbTypeorStateTypeis nil, and updated/added test cases inmapper_test.goandextractor_test.go.Impact & Compatibility
VerbTypeorStateTypeat generation time. Valid.khifile compatibility is unaffected.Remaining Issues & Future Work
None.