Skip to content

slightly improve error tracking related to appsec-config loading#4535

Draft
buixor wants to merge 1 commit into
masterfrom
improve-appsec-config-error-tracking
Draft

slightly improve error tracking related to appsec-config loading#4535
buixor wants to merge 1 commit into
masterfrom
improve-appsec-config-error-tracking

Conversation

@buixor

@buixor buixor commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings July 2, 2026 12:48
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

@buixor: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind enhancement
  • /kind refactoring
  • /kind fix
  • /kind chore
  • /kind dependencies
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

@buixor: There are no area labels on this PR. You can add as many areas as you see fit.

  • /area agent
  • /area local-api
  • /area cscli
  • /area appsec
  • /area security
  • /area configuration
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 troubleshooting for appsec-config loading/build failures by tracking which config file paths were merged into an AppsecConfig, and surfacing that provenance when appsec runtime build fails (so users can more quickly identify which config(s) to inspect).

Changes:

  • Added AppsecConfig.LoadedFrom and populated it during LoadByPath() to preserve merge/load order.
  • Added tests asserting LoadedFrom is populated during multi-file loads.
  • Wrapped appsec Build() errors in the acquisition appsec source with the list of loaded config file paths.

Reviewed changes

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

File Description
pkg/appsec/appsec.go Introduces LoadedFrom metadata and records it during LoadByPath().
pkg/appsec/appsec_config_test.go Adds assertions for LoadedFrom and a build-failure test case.
pkg/acquisition/modules/appsec/config.go Enriches Build() failure errors with the LoadedFrom path list.

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

Comment on lines +202 to +205
// A hook filter that fails to compile must surface an error naming the
// appsec-config file it came from, so `crowdsec -t` points at the faulty config.
func TestBuildErrorNamesSourceFile(t *testing.T) {
cfg := newTestConfig()
Comment thread pkg/appsec/appsec.go
Comment on lines +523 to +525
// LoadedFrom lists the appsec-config file(s) merged into this config, in load order.
// Used to track error origins at load time
LoadedFrom []string `yaml:"-"`
@codecov

codecov Bot commented Jul 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.29%. Comparing base (1f5e9c8) to head (c2de121).

Files with missing lines Patch % Lines
pkg/acquisition/modules/appsec/config.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #4535       +/-   ##
===========================================
+ Coverage   41.78%   64.29%   +22.50%     
===========================================
  Files         480      489        +9     
  Lines       37202    37799      +597     
===========================================
+ Hits        15546    24303     +8757     
+ Misses      19746    11202     -8544     
- Partials     1910     2294      +384     
Flag Coverage Δ
bats 41.78% <33.33%> (-0.01%) ⬇️
unit-linux 40.05% <33.33%> (?)

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

☔ View full report in Codecov by Harness.
📢 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.

@blotus blotus marked this pull request as draft July 6, 2026 12:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants