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/punctuation in compare error messages (including “entries” and “access”).
    • Improved the formatting of reference-config related errors by removing unnecessary quotes.
    • Corrected inline-diff error wording for “error occurred during diff” and improved messaging when template-side values can’t be accessed.
  • Tests
    • Updated golden outputs to match the corrected error text 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

Walkthrough

Compare error messages were updated for quoting and spelling, and the matching golden files were adjusted. Inline diff preprocessing error text now uses the corrected “access” spelling.

Changes

Compare error message text updates

Layer / File(s) Summary
Reference config error formatting
pkg/compare/compare.go, pkg/compare/testdata/NoInput/localerr.golden, pkg/compare/testdata/ReferenceConfigFileDoesntExist/localerr.golden
Reference config file error strings no longer include embedded quotes, and the matching golden outputs now use the unquoted form.
Generation and diff message spelling
pkg/compare/compare.go, pkg/compare/testdata/UserOverride/localfailOutputerr.golden
The user override generation message and diff execution error text correct spelling, and the UserOverride golden output matches the updated wording.
Inline diff preprocessing errors
pkg/compare/compare.go, pkg/compare/testdata/ReferenceV2PerFieldMatcherValidation/localpathNotItTemplateerr.golden
Template-side and cluster-side nested value error text corrects “acces” to “access”, and the per-field matcher validation golden output reflects the updated message.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 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 accurately summarizes the main change: user-facing error message typo fixes and removal of literal quotes.
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 PR only updates error strings and golden outputs; no Ginkgo test titles were added or modified.
Test Structure And Quality ✅ Passed PASS: The PR only changes compare.go string literals and golden fixtures; no Ginkgo spec/test code was modified, so the checklist is not applicable.
Microshift Test Compatibility ✅ Passed PR only changes compare.go and golden/unit-test fixtures; no new Ginkgo e2e specs or MicroShift-unsupported APIs were added.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Only error strings and golden files changed; no new Ginkgo e2e tests or topology-sensitive assertions were added.
Topology-Aware Scheduling Compatibility ✅ Passed Only CLI error-string and golden-output files changed; no manifests, operators, controllers, or scheduling constraints were introduced.
Ote Binary Stdout Contract ✅ Passed PR only updates error strings and goldens; the main() startup path just wires IOStreams and does not write to stdout.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed Only compare.go and golden files changed; no new Ginkgo e2e tests, IPv4-only assumptions, or external connectivity requirements were added.
No-Weak-Crypto ✅ Passed Touched files only change user-facing strings/goldens; no weak crypto, custom crypto, or secret comparison code was added.
Container-Privileges ✅ Passed Touched files only change error strings/goldens; none contain privileged, hostPID/Network/IPC, allowPrivilegeEscalation, SYS_ADMIN, or runAsUser:0.
No-Sensitive-Data-In-Logs ✅ Passed The patch only fixes user-facing error strings and golden outputs; it adds no new logging or sensitive-value exposure.
✨ 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
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 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.

@openshift-ci

openshift-ci Bot commented Jun 29, 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