Skip to content

fix: Deeply nested lines causing panic when saving config#783

Merged
JosephKav merged 1 commit intorelease-argus:masterfrom
bjw-s:fix-deep-nesting
Jan 6, 2026
Merged

fix: Deeply nested lines causing panic when saving config#783
JosephKav merged 1 commit intorelease-argus:masterfrom
bjw-s:fix-deep-nesting

Conversation

@bjw-s
Copy link
Copy Markdown
Contributor

@bjw-s bjw-s commented Jan 6, 2026

When the config file contained a deeply nested line (for example, see my nested JSON here) this would crash the reorderYAML function as the parentKey slice was limited to only 10 items.

panic: runtime error: index out of range [10] with length 10

goroutine 67 [running]:
github.com/release-argus/Argus/config.(*Config).reorderYAML(0xc000242b08, {0xc0005fa008, 0xc5, 0xc9})
     /build/config/save.go:160 +0xf85
github.com/release-argus/Argus/config.(*Config).Save(0xc000242b08)
     /build/config/save.go:106 +0x3fb
github.com/release-argus/Argus/config.(*Config).SaveHandler(0xc000242b08, {0xfa6a38, 0xc00024a040})
     /build/config/save.go:54 +0x5c
github.com/release-argus/Argus/config.(*Config).Load.func1()
     /build/config/init.go:138 +0x1f
golang.org/x/sync/errgroup.(*Group).Go.func1()
     /root/go/pkg/mod/golang.org/x/sync@v0.19.0/errgroup/errgroup.go:93 +0x50
created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 1
     /root/go/pkg/mod/golang.org/x/sync@v0.19.0/errgroup/errgroup.go:78 +0x95

This PR grows the parentKey automatically if needed so that these config files can be parsed again.

Side note: this behavior of automatically modifying/sorting and saving the configuration file breaks the usage pattern where the configuration file is read-only (for example when being mounted from a Kubernetes ConfigMap). Is there a way to disable this behavior?

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 6, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.82%. Comparing base (3e729fa) to head (fbb5a15).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #783      +/-   ##
==========================================
- Coverage   98.96%   98.82%   -0.14%     
==========================================
  Files         137      137              
  Lines        9218     9222       +4     
==========================================
- Hits         9122     9113       -9     
- Misses         73       84      +11     
- Partials       23       25       +2     

☔ 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.

@JosephKav
Copy link
Copy Markdown
Collaborator

Nice fix, thanks for doing this. Didn't account for the possibility of deeply nested config!

w.r.t wanting a read-only config, you can disable the routes that modify the config - https://release-argus.io/docs/config/settings/

settings:
  web:
    disabled_routes:
      - service_create  # Creation of new services
      - service_update  # Updating of existing services
      - service_delete  # Deletion of services

@bjw-s
Copy link
Copy Markdown
Contributor Author

bjw-s commented Jan 6, 2026

Nice fix, thanks for doing this.

Thanks :) And no problem at all!

w.r.t wanting a read-only config, you can disable the routes that modify the config

That's fair, but what I've noticed is that with a read-only file (such as what happens when you mount a Kubernetes ConfigMap into the pod but the behavior can be replicated by providing it with any read-only config file), Argus will now still try to update the file shortly after startup, even though those endpoints are disabled. My guess is that this happens because it tries to write back the massaged (with reordering etc done) config file back to disk.

@JosephKav JosephKav added bug Something isn't working go Pull requests that update Go code labels Jan 6, 2026
@JosephKav
Copy link
Copy Markdown
Collaborator

Oh yeah, it'll save if your config is modified on startup. I'll add a config/cli setting for readonly mode

@JosephKav JosephKav merged commit 1df1adc into release-argus:master Jan 6, 2026
7 checks passed
@Argus-Bot Argus-Bot mentioned this pull request Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants