Skip to content

fix: Preserve newline before apiVersion in nico-rest-api configmap#509

Open
jeremypruitt wants to merge 1 commit intoNVIDIA:mainfrom
jeremypruitt:fix/configmap-validateauth-trim-newline
Open

fix: Preserve newline before apiVersion in nico-rest-api configmap#509
jeremypruitt wants to merge 1 commit intoNVIDIA:mainfrom
jeremypruitt:fix/configmap-validateauth-trim-newline

Conversation

@jeremypruitt
Copy link
Copy Markdown

Description

The validateAuth include at the top of nico-rest-api/templates/configmap.yaml uses {{- ... -}}, which strips whitespace on both sides of the action. When validateAuth succeeds (the common case — auth is configured correctly), the helper produces empty output, and the trailing -}} strips the newline that should separate the action from apiVersion: v1. The result is that apiVersion: v1 gets glued onto the end of the SPDX header's last comment line, producing invalid YAML that breaks helm install.

Reproduction

helm template test helm/charts/nico-rest/charts/nico-rest-api \
  -s templates/configmap.yaml \
  --set global.image.repository=foo --set global.image.tag=v1 --set global.imagePullSecrets= \
  --set config.keycloak.enabled=true \
  --set config.keycloak.baseURL=https://kc.example.com \
  --set config.keycloak.realm=nico \
  --set config.keycloak.clientID=nico \
  --set config.db.user=nico --set config.db.password=changeme \
  --set config.db.host=localhost --set config.db.port=5432 --set config.db.name=nico \
  --set secrets.dbCreds=false

Before (broken)

# See the License for the specific language governing permissions and
# limitations under the License.apiVersion: v1
kind: ConfigMap

After (this PR)

# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap

Root cause

{{- ... -}} strips all preceding whitespace (including the blank line above the action and the trailing newline of the previous comment) and all trailing whitespace (the newline before apiVersion). When the include's success-path output is "", the comment line and apiVersion: v1 end up directly concatenated. Replacing -}} with }} preserves the trailing newline.

Type of Change

  • Feature - New feature or functionality (feat:)
  • Fix - Bug fixes (fix:)
  • Chore - Modification or removal of existing functionality (chore:)
  • Refactor - Refactoring of existing functionality (refactor:)
  • Docs - Changes in documentation or OpenAPI schema (docs:)
  • CI - Changes in GitHub workflows. Requires additional scrutiny (ci:)
  • Version - Issuing a new release version (version:)

Services Affected

  • API - API models or endpoints updated
  • Workflow - Workflow service updated
  • DB - DB DAOs or migrations updated
  • Site Manager - Site Manager updated
  • Cert Manager - Cert Manager updated
  • Site Agent - Site Agent updated
  • RLA - RLA service updated
  • Powershelf Manager - Powershelf Manager updated
  • NVSwitch Manager - NVSwitch Manager updated

(Helm chart for the API service.)

Related Issues (Optional)

The same one-line change is bundled inside #507 ("Feat/rename ncx to nico") alongside unrelated rename work. Per CONTRIBUTING.md ("Keep pull requests focused on a single change"), this PR extracts the configmap fix so it can land independently.

cc @shayan1995 — your #507 already includes this exact fix; opening this narrower PR so it can land on its own without waiting for the rest of the rename work. Happy to close in favor of #507 if you'd prefer it stay bundled there.

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • No testing required (docs, internal refactor, etc.)

Verified with helm template before/after on a clean checkout (see Reproduction section). Existing chart unit tests not affected.

Additional Notes

The same whitespace-trim pattern ({{- include ... -}} at the top of a file with text above) does not currently appear in any other template in helm/charts/nico-rest/, so this is an isolated occurrence.

Drafted with Claude assistance; manually verified by rendering the chart before/after with helm template and confirming apiVersion: v1 lands on its own line.

The validateAuth include used {{- ... -}} which strips whitespace on
both sides. When validateAuth's success path produces empty output, the
trailing -}} strips the newline before apiVersion: v1, gluing it onto
the end of the SPDX header's final comment line:

  # limitations under the License.apiVersion: v1

This produces invalid YAML and the chart fails to install. Removing the
trailing dash preserves the newline.

Verified by rendering with helm template before/after.

Signed-off-by: Jeremy Pruitt <jeremypruitt@me.com>
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented May 9, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 9, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 0cffa2e4-4ee2-478c-91e9-00caf9b6b1ce

📥 Commits

Reviewing files that changed from the base of the PR and between 5cfe1d9 and 87c08ab.

📒 Files selected for processing (1)
  • helm/charts/nico-rest/charts/nico-rest-api/templates/configmap.yaml

Summary by CodeRabbit

  • Chores
    • Updated internal deployment configuration templating.

No user-facing changes in this release.

Walkthrough

The ConfigMap template in the Helm chart removes the trailing whitespace-trimming operator from the nico-rest-api.validateAuth include invocation. The change alters how Go template delimiters render the included auth-validation content, allowing whitespace to be preserved in the final ConfigMap output.

Changes

Helm Template Whitespace Behavior

Layer / File(s) Summary
Template Include Whitespace Adjustment
helm/charts/nico-rest/charts/nico-rest-api/templates/configmap.yaml
Template include call to nico-rest-api.validateAuth changes from {{- ... -}} to {{ ... }}, removing trailing whitespace trimming and preserving output whitespace in the rendered ConfigMap.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing trailing whitespace trimming from the validateAuth include to preserve the newline before apiVersion in the configmap.
Description check ✅ Passed The description is directly related to the changeset, providing detailed context including root cause analysis, reproduction steps, before/after output, and verification methodology.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

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