Skip to content

Fix typos and remove literal quotes in error messages - #276

Open
sebrandon1 wants to merge 1 commit into
openshift:mainfrom
sebrandon1:fix/error-message-typos-and-quotes
Open

Fix typos and remove literal quotes in error messages#276
sebrandon1 wants to merge 1 commit into
openshift:mainfrom
sebrandon1:fix/error-message-typos-and-quotes

Conversation

@sebrandon1

@sebrandon1 sebrandon1 commented May 11, 2026

Copy link
Copy Markdown
Member

Summary

  • Fix spelling errors in error strings: "occurered" → "occurred", "acces" → "access" (×3), "entires" → "entries"
  • Remove unnecessary escaped literal quotes from noRefFileWasPassed and refFileNotExistsError error constants that were appearing in user-facing output
  • Update 4 golden test files to match corrected strings

Jira: https://redhat.atlassian.net/browse/CNF-23706

Summary by CodeRabbit

  • Bug Fixes
    • Corrected spelling and punctuation in comparison error messages, including “entries” and “access.”
    • Improved reference-configuration error formatting by removing unnecessary quotation marks.
    • Clarified diff and inline-diff error messages while preserving non-error handling for missing cluster-side values.
  • Tests
    • Updated expected outputs to reflect the corrected wording and formatting.

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 11, 2026
@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 88072c37-30ee-4425-bb82-28fe6ccd14d4

📥 Commits

Reviewing files that changed from the base of the PR and between c051d1b and 3fd8eec.

📒 Files selected for processing (5)
  • pkg/compare/compare.go
  • pkg/compare/testdata/NoInput/localerr.golden
  • pkg/compare/testdata/ReferenceConfigFileDoesntExist/localerr.golden
  • pkg/compare/testdata/ReferenceV2PerFieldMatcherValidation/localpathNotItTemplateerr.golden
  • pkg/compare/testdata/UserOverride/localfailOutputerr.golden
🚧 Files skipped from review as they are similar to previous changes (5)
  • pkg/compare/testdata/UserOverride/localfailOutputerr.golden
  • pkg/compare/testdata/ReferenceConfigFileDoesntExist/localerr.golden
  • pkg/compare/testdata/NoInput/localerr.golden
  • pkg/compare/compare.go
  • pkg/compare/testdata/ReferenceV2PerFieldMatcherValidation/localpathNotItTemplateerr.golden

Walkthrough

Compare error messages now use corrected quoting and spelling. Matching golden files reflect the updated output. Cluster-side missing inline-diff values remain non-error.

Changes

Compare error messages

Layer / File(s) Summary
Compare error message corrections
pkg/compare/compare.go
Reference configuration errors no longer include embedded quotes. Override, diff, and inline-diff error messages use corrected spelling.
Golden output synchronization
pkg/compare/testdata/NoInput/localerr.golden, pkg/compare/testdata/ReferenceConfigFileDoesntExist/localerr.golden, pkg/compare/testdata/ReferenceV2PerFieldMatcherValidation/localpathNotItTemplateerr.golden, pkg/compare/testdata/UserOverride/localfailOutputerr.golden
Golden outputs now match the corrected error formatting and spelling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: natifridman, zzztx

🚥 Pre-merge checks | ✅ 14 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (14 passed)
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 typo corrections and removal of literal quotes from user-facing error messages.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed The PR changes only error strings and golden files. No Ginkgo test declarations or test-title additions are present.
Test Structure And Quality ✅ Passed PASS: The commit changes only error strings and four golden fixtures. It adds no Ginkgo tests, cluster resources, waits, or assertion code to review.
Microshift Test Compatibility ✅ Passed The PR changes only compare.go and four golden files; no Ginkgo tests, unavailable API references, namespaces, or MicroShift-sensitive assumptions were added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed The PR changes one production Go file and four golden files only; it adds no Ginkgo e2e tests or multi-node/HA assumptions requiring SNO review.
Topology-Aware Scheduling Compatibility ✅ Passed The commit changes only error strings in pkg/compare/compare.go and four golden files; it adds no manifests, controllers, replicas, affinities, topology constraints, selectors, tolerations, or PDBs.
Ote Binary Stdout Contract ✅ Passed The PR changes only error strings and golden files; it adds no process-level stdout writes or logging setup changes, and vendored klog defaults to stderr.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed The commit changes one Go source file and four golden files; it adds no Ginkgo e2e tests, IPv4 assumptions, or external connectivity requirements.
No-Weak-Crypto ✅ Passed The commit changes only error strings and golden files; it adds no weak crypto, custom crypto, secret comparisons, or token handling. Existing hashing uses SHA-256.
Container-Privileges ✅ Passed The diff changes only Go error strings and golden text files; no container/Kubernetes manifest or listed privilege setting appears in the changed files.
No-Sensitive-Data-In-Logs ✅ Passed The commit only changes wording in errors and golden files; no passwords, tokens, keys, PII, hostnames, or new logging statements were added.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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

@openshift-ci
openshift-ci Bot requested review from natifridman and zzztx May 11, 2026 20:29
@openshift-ci

openshift-ci Bot commented May 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign adhil0 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@sebrandon1
sebrandon1 force-pushed the fix/error-message-typos-and-quotes branch from c12b2de to edd237d Compare May 11, 2026 20:32
@openshift-ci openshift-ci Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 11, 2026
@sebrandon1
sebrandon1 force-pushed the fix/error-message-typos-and-quotes branch from edd237d to c6f72ee Compare June 15, 2026 17:13
@sebrandon1
sebrandon1 force-pushed the fix/error-message-typos-and-quotes branch from c6f72ee to c051d1b Compare June 29, 2026 15:40

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/compare/compare.go`:
- Around line 1070-1075: The inline-diff preprocessing in compare.go is treating
any false found state from NestedString as a missing field before checking the
returned error, which can mask malformed cluster data. Update the logic around
clusterValue, exist, and err so the error from NestedString is handled first and
reported with the existing fmt.Errorf path in the inline-diff preprocessing
block, and only continue when the field is truly absent with no error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 14e0a7d4-53c5-4e75-9fd6-b1e3330053ee

📥 Commits

Reviewing files that changed from the base of the PR and between c6f72ee and c051d1b.

📒 Files selected for processing (5)
  • pkg/compare/compare.go
  • pkg/compare/testdata/NoInput/localerr.golden
  • pkg/compare/testdata/ReferenceConfigFileDoesntExist/localerr.golden
  • pkg/compare/testdata/ReferenceV2PerFieldMatcherValidation/localpathNotItTemplateerr.golden
  • pkg/compare/testdata/UserOverride/localfailOutputerr.golden
✅ Files skipped from review due to trivial changes (4)
  • pkg/compare/testdata/NoInput/localerr.golden
  • pkg/compare/testdata/ReferenceConfigFileDoesntExist/localerr.golden
  • pkg/compare/testdata/ReferenceV2PerFieldMatcherValidation/localpathNotItTemplateerr.golden
  • pkg/compare/testdata/UserOverride/localfailOutputerr.golden

Comment thread pkg/compare/compare.go
Comment on lines 1070 to +1075
clusterValue, exist, err := NestedString(obj.clusterObj.Object, listedPath...)
if !exist {
continue // if value does not appear in cluster CR then there will be a diff anyway and this is not an error
}
if err != nil {
errs = append(errs, fmt.Errorf("failed to acces value in cluster cr of field %s that uses inline diff func: %w", pathToKey, err))
errs = append(errs, fmt.Errorf("failed to access value in cluster cr of field %s that uses inline diff func: %w", pathToKey, err))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

In k8s.io/apimachinery v0.34.0, can unstructured.NestedString return found=false together with a non-nil error when traversal hits a non-map value or the resolved field is not a string?

💡 Result:

In k8s.io/apimachinery v0.34.0, the function unstructured.NestedString does not return found=false together with a non-nil error. Instead, its behavior depends on whether the field is found and whether it is a string: 1. If the field is found and it is a string, it returns the string, found=true, and error=nil [1][2]. 2. If the field is not found (or an intermediate path is missing), it returns an empty string, found=false, and error=nil [1][2]. 3. If the field is found but is not a string, it returns an empty string, found=false, and a non-nil error (specifically an accessor error) [1][2]. The implementation explicitly checks the found status and error from NestedFieldNoCopy before performing a type assertion [1][2]: func NestedString(obj map[string]interface{}, fields...string) (string, bool, error) { val, found, err:= NestedFieldNoCopy(obj, fields...) if!found || err!= nil { return "", found, err } s, ok:= val.(string) if!ok { return "", false, fmt.Errorf("%v accessor error: %v is of the type %T, expected string", jsonPath(fields), val, val) } return s, true, nil } Therefore, a non-nil error is only returned when the field exists but is of an incorrect type, and in that specific case, found is returned as false [1][2]. If the field is missing (found=false), the error is nil [1][2].

Citations:


Check the error before treating the cluster value as missing. unstructured.NestedString returns found=false and a non-nil error for type mismatches, so the current if !exist { continue } path can hide malformed cluster data as “missing” instead of surfacing the inline-diff preprocessing error.

Suggested fix
 		clusterValue, exist, err := NestedString(obj.clusterObj.Object, listedPath...)
-		if !exist {
-			continue // if value does not appear in cluster CR then there will be a diff anyway and this is not an error
-		}
 		if err != nil {
 			errs = append(errs, fmt.Errorf("failed to access value in cluster cr of field %s that uses inline diff func: %w", pathToKey, err))
 			continue
 		}
+		if !exist {
+			continue // if value does not appear in cluster CR then there will be a diff anyway and this is not an error
+		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
clusterValue, exist, err := NestedString(obj.clusterObj.Object, listedPath...)
if !exist {
continue // if value does not appear in cluster CR then there will be a diff anyway and this is not an error
}
if err != nil {
errs = append(errs, fmt.Errorf("failed to acces value in cluster cr of field %s that uses inline diff func: %w", pathToKey, err))
errs = append(errs, fmt.Errorf("failed to access value in cluster cr of field %s that uses inline diff func: %w", pathToKey, err))
clusterValue, exist, err := NestedString(obj.clusterObj.Object, listedPath...)
if err != nil {
errs = append(errs, fmt.Errorf("failed to access value in cluster cr of field %s that uses inline diff func: %w", pathToKey, err))
continue
}
if !exist {
continue // if value does not appear in cluster CR then there will be a diff anyway and this is not an error
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/compare/compare.go` around lines 1070 - 1075, The inline-diff
preprocessing in compare.go is treating any false found state from NestedString
as a missing field before checking the returned error, which can mask malformed
cluster data. Update the logic around clusterValue, exist, and err so the error
from NestedString is handled first and reported with the existing fmt.Errorf
path in the inline-diff preprocessing block, and only continue when the field is
truly absent with no error.

Fix spelling errors in error strings ("occurered" → "occurred",
"acces" → "access", "entires" → "entries") and remove unnecessary
escaped literal quotes wrapping two error constants. Update golden
test files to match.
@sebrandon1
sebrandon1 force-pushed the fix/error-message-typos-and-quotes branch from c051d1b to 3fd8eec Compare July 31, 2026 02:35
@openshift-ci

openshift-ci Bot commented Jul 31, 2026

Copy link
Copy Markdown

@sebrandon1: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant