Skip to content

fix: correctly parse multi-value list flags in setup_config#539

Closed
nishantxscooby wants to merge 15 commits intocertego:developfrom
nishantxscooby:fix/setup-config-multivalue-clean
Closed

fix: correctly parse multi-value list flags in setup_config#539
nishantxscooby wants to merge 15 commits intocertego:developfrom
nishantxscooby:fix/setup-config-multivalue-clean

Conversation

@nishantxscooby
Copy link
Contributor

@nishantxscooby nishantxscooby commented Jan 20, 2026

Fixes #499

Fix multi-value flag parsing in setup_config

Problem
List values passed via --append, --override, and --remove were parsed using naive comma splitting, which breaks quoted values with spaces and ISO2 country codes.

Solution
Use ast.literal_eval to safely parse list literals, with a fallback to the previous comma-based logic for backward compatibility.

Scope

  • Single-file change
  • No validator changes
  • No migrations
  • No formatting-only changes

Testing
Parsing logic was validated directly for:

  • multi-value lists with spaces
  • ISO2 country codes
  • booleans, numbers, and fallback behavior

@nishantxscooby
Copy link
Contributor Author

Hi @Lorygold 👋

This PR is a clean restart for issue #499 with a very narrow scope.
I’ve limited the change to a single file and avoided any formatter or unrelated changes.

The fix replaces naive comma-splitting with ast.literal_eval (with a backward-compatible fallback) to correctly handle multi-value flags, quoted strings, and ISO2 country codes.

Thanks for reviewing :)

@Lorygold
Copy link
Contributor

Are you sure that it works? I get:

$ ./manage.py setup_config -a filtered_alerts_types=['New Device', 'User Risk Threshold', 'Anonymous IP Login']
usage: manage.py setup_config [-h] [--version] [-v {0,1,2,3}] [--settings SETTINGS] [--pythonpath PYTHONPATH] [--traceback] [--no-color] [--force-color] [--skip-checks]
                              [--execution_mode {manual,automatic}] [-o FIELD=[VALUES]] [-r FIELD=[VALUES]] [-a FIELD=[VALUES]] [--set-default-values] [--force]
manage.py setup_config: error: unrecognized arguments: User Risk Threshold, Anonymous IP Login]

Test it locally and add a test in the test_management_commands.py with that command-line to check the correct behavior

@nishantxscooby
Copy link
Contributor Author

Hello, I think you're right, and I've been trying to fix this up lately but seems like am again stuck in the CI checks loop, can you please help me get out of this loop?

thankyou :)

@Lorygold
Copy link
Contributor

You can follow the CONTRIBUTING.md file for linters troubleshooting. Did you run them locally? Which are the results and the linters versions?

@nishantxscooby
Copy link
Contributor Author

Hello, okay - thanks for the guidance. I'll look into it as soon as possible, am out for next 3-4 days. Sorry for the inconvenience.

@nishantxscooby nishantxscooby force-pushed the fix/setup-config-multivalue-clean branch from f220ad9 to ae323c3 Compare January 30, 2026 18:12
nishantxscooby added a commit to nishantxscooby/BuffaLogs that referenced this pull request Jan 30, 2026
nishantxscooby added a commit to nishantxscooby/BuffaLogs that referenced this pull request Jan 30, 2026
@nishantxscooby nishantxscooby force-pushed the fix/setup-config-multivalue-clean branch from a8bc9e5 to a8efea6 Compare January 30, 2026 19:03
@nishantxscooby nishantxscooby force-pushed the fix/setup-config-multivalue-clean branch from a8efea6 to c48c707 Compare January 30, 2026 19:21
@Lorygold
Copy link
Contributor

Lorygold commented Feb 9, 2026

@nishantxscooby please close this PR, since you opened another one.

for next times, work on the same PR, it's not necessary to open a new one, changes can be done in the original one

@nishantxscooby
Copy link
Contributor Author

Hey! @Lorygold

Sure, I'll keep that in mind, sorry for the chaos.

Also please assign with some issue which are available at moment.

Thankyou :)

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.

[REFACTOR] <Django command>: setup_config command does not accept multiple values for list fields

2 participants