Skip to content

fix(backend): validate non-nil VerbType in changeset and assign VerbUnknown fallback in autoscaler and oss k8s - #1059

Merged
kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-znqlomkykzxs
Sep 29, 2026
Merged

kyasbal merged 1 commit into
GoogleCloudPlatform:mainfrom
kyasbal:push-znqlomkykzxs

Conversation

@kyasbal

@kyasbal kyasbal commented Sep 29, 2026

Copy link
Copy Markdown
Member

Background & Problem

In the KHI frontend, hovering over certain timeline revisions could crash the UI with Error: Verb ID 0 not found from TimelineStore._getRevisionVerb.

This runtime crash occurred because some backend inspection tasks generated StagingRevision objects without specifying a VerbType (leaving it nil), and the serialization layer in pkg/model/khifile/v6/changeset.go (flushRevision) lacked validation for nil VerbType and StateType. 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:

  1. GKE Autoscaler mapper (pkg/task/inspection/googlecloud/gkeautoscaler/impl/mapper.go): mapResultInfo created StagingRevision for cluster autoscaler timeline entries without setting VerbType.
  2. OSS Kubernetes audit log extractor (pkg/task/inspection/oss/k8s/extractor.go): ExtractOSSK8sAuditLog returned an empty K8sAuditLogFieldSet when neither auditID nor objectRef was present, leaving Verb unassigned.

Solution Approach

  1. Strict validation at serialization boundary:
    Updated flushRevision in pkg/model/khifile/v6/changeset.go to explicitly return an error if r.VerbType == nil or r.StateType == nil, identifying the affected path ID and failing fast rather than emitting invalid revisions.
  2. Assign fallback verb in Autoscaler mapper:
    Updated mapResultInfo in pkg/task/inspection/googlecloud/gkeautoscaler/impl/mapper.go to explicitly set VerbType: inspectioncore.VerbUnknown on the autoscaler timeline StagingRevision.
  3. Assign fallback verb in OSS K8s extractor:
    Updated ExtractOSSK8sAuditLog in pkg/task/inspection/oss/k8s/extractor.go to assign Verb: k8saudit.VerbUnknown on the fallback return when auditID and objectRef are absent.
  4. Unit test additions:
    Added unit tests in changeset_test.go to verify error behavior when VerbType or StateType is nil, and updated/added test cases in mapper_test.go and extractor_test.go.

Impact & Compatibility

  • Serialization now catches and rejects revisions with nil VerbType or StateType at generation time. Valid .khi file compatibility is unaffected.

Remaining Issues & Future Work

None.

@kyasbal kyasbal added the type:bug Something isn't working as expected label Sep 29, 2026
@kyasbal
kyasbal requested a review from K53 as a code owner September 29, 2026 05:12
@kyasbal kyasbal added area:backend-parser Log parsers and log timeline mapper tasks area:khifile .khi file format, serialization, and schema labels Sep 29, 2026

@gemini-code-assist gemini-code-assist Bot 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.

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
kyasbal enabled auto-merge September 29, 2026 05:16
@kyasbal
kyasbal added this pull request to the merge queue Sep 29, 2026
Merged via the queue into GoogleCloudPlatform:main with commit a50583b Sep 29, 2026
17 checks passed
@kyasbal
kyasbal deleted the push-znqlomkykzxs branch September 29, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:backend-parser Log parsers and log timeline mapper tasks area:khifile .khi file format, serialization, and schema type:bug Something isn't working as expected

1 participant