Skip to content

Update error message in GitOps when unknown env vars are encountered#46476

Open
sgress454 wants to merge 2 commits into
mainfrom
sgress454/44053-escape-in-generate-gitops
Open

Update error message in GitOps when unknown env vars are encountered#46476
sgress454 wants to merge 2 commits into
mainfrom
sgress454/44053-escape-in-generate-gitops

Conversation

@sgress454
Copy link
Copy Markdown
Contributor

@sgress454 sgress454 commented May 29, 2026

Related issue: Resolves #44053

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.

Testing

  • Added/updated automated tests
  • QA'd all new/changed functionality manually

Summary by CodeRabbit

  • Bug Fixes
    • Error messages for undefined environment variables in GitOps configurations now include clearer, actionable guidance with examples of how to escape literal dollar-sign syntax (e.g., showing escaped forms). This improves clarity when a variable is missing and helps users distinguish between intended variable references and literal values, reducing confusion.

Review Change Stack

Copilot AI review requested due to automatic review settings May 29, 2026 18:14
@sgress454 sgress454 requested a review from a team as a code owner May 29, 2026 18:14
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves the GitOps environment-variable error message so users who intended literal $VAR text are told how to escape it, addressing the round-trip issue described in #44053.

Changes:

  • Adds escape guidance to missing environment variable errors in expandEnv.
  • Updates unit and GitOps tests to expect the new message.
  • Adds a changelog entry for the user-visible error message improvement.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/spec/spec.go Builds a clearer missing-env-var error with $VAR / ${VAR} escape guidance.
pkg/spec/spec_test.go Updates TestExpandEnv expectations for the new error wording.
pkg/spec/gitops_test.go Updates GitOps missing-env-var assertion for the new message.
changes/44053-improve-env-var-error-msg Documents the user-visible GitOps error message update.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3dbedb77-73ab-4422-a1ef-28ffd0b605d7

📥 Commits

Reviewing files that changed from the base of the PR and between 418e221 and 08f3330.

📒 Files selected for processing (1)
  • changes/44053-improve-env-var-error-msg
✅ Files skipped from review due to trivial changes (1)
  • changes/44053-improve-env-var-error-msg

Walkthrough

This PR improves error messages shown when GitOps files reference undefined environment variables. expandEnv now reports which variable is unset and shows how to escape the literal form used in the source (e.g., advise \$VAR for $VAR or \${VAR} for ${VAR}). Tests were updated to verify the exact new messages and a changelog entry documents the change.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: updating the error message for unknown environment variables in GitOps.
Description check ✅ Passed The description includes the related issue (#44053), indicates a changes file was added, automated tests were updated, and manual QA was performed.
Linked Issues check ✅ Passed The code changes directly address issue #44053 by improving error messages to advise users how to escape literal dollar signs in environment variable references.
Out of Scope Changes check ✅ Passed All changes are scoped to the linked issue: a changes file, error message improvements in spec.go, and corresponding test updates in spec_test.go and gitops_test.go.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sgress454/44053-escape-in-generate-gitops

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 and usage tips.

@sgress454 sgress454 force-pushed the sgress454/44053-escape-in-generate-gitops branch from 418e221 to 08f3330 Compare May 30, 2026 18:30
@codecov
Copy link
Copy Markdown

codecov Bot commented May 30, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 66.81%. Comparing base (1f934e1) to head (08f3330).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #46476      +/-   ##
==========================================
- Coverage   66.81%   66.81%   -0.01%     
==========================================
  Files        2809     2809              
  Lines      223584   223588       +4     
  Branches    11309    11309              
==========================================
- Hits       149382   149381       -1     
- Misses      60647    60649       +2     
- Partials    13555    13558       +3     
Flag Coverage Δ
backend 68.53% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

generate-gitops output is not round-trip compatible with gitops when string values contain $

3 participants