Skip to content

fix(watcher): correct swapped error messages for ErrMissingImageTag and ErrMissingImageID - #445

Merged
matthyx merged 1 commit into
kubescape:mainfrom
Rucha0901:fix/swap-missing-image-error-messages
Oct 21, 2026
Merged

matthyx merged 1 commit into
kubescape:mainfrom
Rucha0901:fix/swap-missing-image-error-messages

Conversation

@Rucha0901

@Rucha0901 Rucha0901 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Signed Commits

  • Yes, I signed my commits.

In watcher/watchhandler.go, ErrMissingImageTag had the error message "missing image ID" and ErrMissingImageID had "missing image tag". This PR swaps them so each sentinel error contains the correct message matching its variable name.

How to Test

Run the watcher unit tests:
go test -v -run "TestValidateContainerData|TestHandleSBOMEvents" ./watcher

Screenshot

Fix and Test Output

Related issue:

Summary by CodeRabbit

  • Bug Fixes
    • Corrected error messages so missing image tags and missing image IDs are accurately identified.

…sages

Signed-off-by: Rucha0901 <imt_2025071@iiitm.ac.in>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 008fde95-c9a7-45e7-abcf-5e755a49dc4b
📥 Commits

Reviewing files that changed from the base of the PR and between 6bd65ac and 3ba595a.

📒 Files selected for processing: 1
  • watcher/watchhandler.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

The exported ErrMissingImageTag and ErrMissingImageID errors now use the correct messages: “missing image tag” and “missing image ID,” respectively.

Changes: Image error messages

Layer / File(s) Summary
Correct sentinel error messages
watcher/watchhandler.go
ErrMissingImageTag now reports “missing image tag,” and ErrMissingImageID now reports “missing image ID.”

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 3ba59

The PR corrects the image tag and image ID error messages without introducing an established merge risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: correcting the swapped error messages for ErrMissingImageTag and ErrMissingImageID.
Linked Issues check Passed Issue [#444] requires the two sentinel messages to match their variable names. At the reviewed head, watcher/watchhandler.go defines ErrMissingImageTag as fmt.Errorf("missing image tag") and `Er…
Out of Scope Changes check Passed The reviewed change is limited to the two sentinel error message initializers in watcher/watchhandler.go. Both changes directly implement issue [#444]. No unrelated change is evidenced.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Full details: Linked Issues check

Explanation

Issue [#444] requires the two sentinel messages to match their variable names. At the reviewed head, watcher/watchhandler.go defines ErrMissingImageTag as fmt.Errorf("missing image tag") and ErrMissingImageID as fmt.Errorf("missing image ID"). The change satisfies both coding requirements.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@matthyx matthyx 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.

Approve: the two-line change fixes the diagnostic mismatch reported in #444. validateContainerData already returns the correct sentinel for each missing field; correcting watcher/watchhandler.go:22–23 makes its message accurate without changing validation, sentinel comparisons, or retry behavior. No blocking findings. Independent code and architecture reviews agree (architecture: CLEAR).

Reviewed head 3ba595a47e9845b090fdd98df1665218030f20ba, targeting main. GitHub reports base 6bd65ac2c08716930d00313bcab897ebdde928ab; the actual main ref is 085cb557b44208c9030674e47a8b37825dcd7b7d, whose additional change is confined to continuous scanning and leaves the watcher unchanged.

History: searched repository issues/PRs across all states for both sentinel names, “missing image”, “image tag”, “swapped”, and “watchhandler” (100 results/query; none reached that cap). #379, merged with maintainer approval, fixes #378's separate missing-WLID problem; it does not fix these messages. Its bounded-retry decision remains unaffected. #218 concerns registry tag scanning and #134 deployment image naming; neither supersedes this correction. No rejected equivalent approach was found; this keyword search cannot establish exhaustive absence. Existing PR reviews/inline comments contained no outstanding objections.

Validation: a source-level literal-message assertion fails on current main and passes at this head; git diff --check passes. Existing watcher tests assert sentinel identity, so adding literal-message assertions would be useful but nonblocking. In a credential-free Docker container (Go 1.27.1, read-only source snapshot, no host sockets), go test -count=1 -run 'TestValidateContainerData|TestHandleSBOMEvents' ./watcher passed (15.851s). This covers the direct validator and SBOM event/retry tests, not the full suite, integration tests, or a separate lint/build run.

GitHub's pull_request_created workflow is action_required, so its tests/lint have not run; DCO, CodeRabbit, GitGuardian, and the two FOSSA status contexts report success. No merge or source changes performed.

@matthyx matthyx added the release Create release label Oct 21, 2026
@matthyx
matthyx merged commit c29b7da into kubescape:main Oct 21, 2026
10 checks passed
@matthyx matthyx moved this to To Archive in KS PRs tracking Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release Create release

Projects

Status: To Archive

Development

Successfully merging this pull request may close these issues.

fix: swapped error messages for ErrMissingImageTag and ErrMissingImageID

2 participants