Skip to content

fix(config): preserve set values in config set - #10647

Merged
jdx merged 1 commit into
jdx:mainfrom
KrishRVH:fix/config-set-preserve-set-values
Jul 1, 2026
Merged

jdx merged 1 commit into
jdx:mainfrom
KrishRVH:fix/config-set-preserve-set-values

Conversation

@KrishRVH

@KrishRVH KrishRVH commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • fix mise config set for set-typed settings so comma-separated values are preserved and deduplicated instead of writing an empty array
  • infer nested settings.* metadata using the full key after settings., including keys like settings.task.skip
  • keep mise settings set SetString parsing consistent by trimming entries, dropping empty entries, deduplicating, and treating [] as an empty set
  • update generated CLI usage docs/spec (docs/cli/config/set.md and mise.usage.kdl) to show the inferred settings-type path instead of forcing --type list

Only SetString parsing is changed; ListString/ListPath parsing is intentionally unchanged.

Testing

  • mise run test:e2e e2e/cli/test_config_set e2e/cli/test_settings_set
  • cargo fmt --all -- --check
  • git diff --check
  • mise run render:usage
  • mise run lint
  • ./target/debug/mise config set --help

This PR description was updated by an AI coding assistant.

Summary by CodeRabbit

  • Bug Fixes

    • Improved config and settings input handling so comma-separated values are trimmed, empty entries are ignored, duplicates are removed, and whitespace-wrapped empty lists are handled correctly.
    • settings.disable_tools and settings.task.skip now normalize more reliably when set through the CLI.
  • Documentation

    • Updated CLI help and usage examples to show simpler input without requiring an explicit type flag.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 34c3bf7f-78b2-42a1-b581-4c8b04bd1734

📥 Commits

Reviewing files that changed from the base of the PR and between c18effa and 721d6c9.

📒 Files selected for processing (6)
  • docs/cli/config/set.md
  • e2e/cli/test_config_set
  • e2e/cli/test_settings_set
  • mise.usage.kdl
  • src/cli/config/set.rs
  • src/cli/settings/set.rs
✅ Files skipped from review due to trivial changes (1)
  • docs/cli/config/set.md
🚧 Files skipped from review as they are similar to previous changes (4)
  • e2e/cli/test_settings_set
  • e2e/cli/test_config_set
  • src/cli/config/set.rs
  • src/cli/settings/set.rs

📝 Walkthrough

Walkthrough

Config and settings set inputs now normalize comma-separated values by trimming, removing empty entries, and deduplicating arrays. E2e coverage was added for settings.disable_tools and settings.task.skip across duplicate, empty, and malformed inputs.

Changes

Set value normalization

Layer / File(s) Summary
Config set parsing
src/cli/config/set.rs, docs/cli/config/set.md, mise.usage.kdl, e2e/cli/test_config_set
ConfigSet::run now strips the settings. prefix for metadata lookup, and the TomlValueTypes::Set branch builds arrays from trimmed comma-separated items while the help text, docs, and e2e test now show and validate the inferred-type form and normalized disable_tools/task.skip values.
Settings set parsing
src/cli/settings/set.rs, e2e/cli/test_settings_set
parse_set_by_comma now trims input, filters empty trimmed elements, and keeps deduplication before TOML conversion; the e2e settings-set test asserts normalized disable_tools output.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Poem

A bunny nibbled comma trails,
then sorted sets with tiny pails.
Empty bits fell through,
duplicates bid adieu—
now tidy arrays hop like gales.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing config set to preserve set values.
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.

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
e2e/cli/test_config_set (1)

16-17: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the persisted TOML too.

This only checks the read path. Because settings.disable_tools is normalized upstream, mise config get can still return ["node", "rust"] even if config set wrote duplicates or spacing incorrectly. Add a cat mise.toml assertion here to pin the storage contract described in the PR.

Suggested assertion
 mise config set settings.disable_tools node,rust,node
 assert "mise config get settings.disable_tools" '["node", "rust"]'
+assert "cat mise.toml" $'[tools.node]\nversion = "latest"\n\n[settings]\ndisable_tools = ["node", "rust"]'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@e2e/cli/test_config_set` around lines 16 - 17, The test around mise config
set for settings.disable_tools only verifies the read path via mise config get,
so it can miss duplicate or spacing bugs in persisted output. Update this e2e
case to also assert the contents of mise.toml after the mise config set call,
using the same settings.disable_tools scenario, so the storage contract is
pinned in addition to the normalized read result.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cli/config/set.rs`:
- Around line 136-139: The array-building logic in set::set_config currently
trims each comma-separated segment but still pushes empty strings into the
toml_edit::Array, so update that loop to skip any item that becomes empty after
trimming. Use the existing value.split(',') handling in set::set_config and its
toml_edit::Array population to filter out blank entries before calling push.

---

Nitpick comments:
In `@e2e/cli/test_config_set`:
- Around line 16-17: The test around mise config set for settings.disable_tools
only verifies the read path via mise config get, so it can miss duplicate or
spacing bugs in persisted output. Update this e2e case to also assert the
contents of mise.toml after the mise config set call, using the same
settings.disable_tools scenario, so the storage contract is pinned in addition
to the normalized read result.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: a8b31c49-4338-4c2b-a518-1a3f2ebdd929

📥 Commits

Reviewing files that changed from the base of the PR and between 66a70e6 and 2f7f788.

📒 Files selected for processing (2)
  • e2e/cli/test_config_set
  • src/cli/config/set.rs

Comment thread src/cli/config/set.rs Resolved
@greptile-apps

greptile-apps Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes two bugs in mise config set and brings mise settings set into alignment: set-typed settings now correctly parse comma-separated values (with deduplication and empty-item filtering), and config set now correctly infers the type of nested settings keys like settings.task.skip by looking up the full dotted path instead of only the last key component.

  • Nested type inference (src/cli/config/set.rs): switches from SETTINGS_META.get(*last_key) to full_key.strip_prefix("settings.").and_then(|k| SETTINGS_META.get(k)), so keys like settings.task.skip resolve to SetString instead of falling back to string inference.
  • Set branch normalization (src/cli/config/set.rs + src/cli/settings/set.rs): both code paths now trim the outer value, filter empty comma-separated segments, and treat "[]" / " [] " as a reset to an empty array, consistent with each other.
  • Tests added in both e2e test files cover deduplication, empty-string reset, "[]" reset, whitespace-wrapped " [] " reset, sparse input, and nested key paths.

Confidence Score: 5/5

Safe to merge — changes are narrowly scoped to Set-type parsing in two CLI commands, with no behavioral changes to other types.

Both the type-inference fix and the normalization logic are straightforward and well-tested. The nested key lookup correctly delegates to the already-generated SETTINGS_META dotted keys. The Set branch and parse_set_by_comma now handle empty input, "[]", whitespace-wrapped "[]", sparse commas, and duplicates consistently with each other.

No files require special attention.

Important Files Changed

Filename Overview
src/cli/config/set.rs Two fixes: (1) SETTINGS_META lookup now uses the full dotted key after stripping "settings." prefix, correctly resolving nested settings like "task.skip"; (2) the Set branch now parses comma-separated items, trims whitespace, filters empties, and handles "[]"/" [] " as a reset signal.
src/cli/settings/set.rs parse_set_by_comma now trims the outer value before checking for empty/"[]", and filters out empty items after splitting on commas; dedup was already applied and remains in place.
e2e/cli/test_config_set New tests cover comma-separated dedup, empty-string reset, "[]" reset, " [] " (whitespace-wrapped) reset, sparse input ("node,, rust,"), and the nested settings.task.skip path.
e2e/cli/test_settings_set New tests validate the updated parse_set_by_comma: dedup + filter for "node,, rust,node", and empty-array reset for " [] ".
docs/cli/config/set.md Example updated to drop the now-unnecessary --type list flag since the type is auto-inferred for settings.disable_tools.
mise.usage.kdl Same example update as docs/cli/config/set.md, keeping generated usage data consistent.

Reviews (7): Last reviewed commit: "fix(config): preserve set values in conf..." | Re-trigger Greptile

Comment thread src/cli/config/set.rs Resolved
@KrishRVH
KrishRVH force-pushed the fix/config-set-preserve-set-values branch 3 times, most recently from befeea6 to c18effa Compare June 26, 2026 19:33
@KrishRVH
KrishRVH marked this pull request as ready for review June 26, 2026 19:37
@KrishRVH
KrishRVH force-pushed the fix/config-set-preserve-set-values branch from f7fe7cd to c53699e Compare July 1, 2026 13:59
@KrishRVH

KrishRVH commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

nightly job seems broken on main as well (ICE while checking rattler_package_streaming, specifically around DynCompatible(DownloadReporter)/reqwest::tokio::get_reader.)

@KrishRVH
KrishRVH force-pushed the fix/config-set-preserve-set-values branch from f0dbae1 to 03a9309 Compare July 1, 2026 15:36
`mise config set` inferred `SetString` settings like
`settings.disable_tools`, but the set serialization path discarded the provided
value and always wrote an empty array. Nested settings such as
`settings.task.skip` also missed settings metadata because lookup only used the
final key segment.

Parse comma-separated set values before deduping, trim whitespace, ignore
empty entries, and treat `[]` as an explicit empty set. Look up settings
metadata using the full key after the `settings.` prefix so nested settings
infer the right type.

Apply the same empty-entry and whitespace handling to `mise settings set`, and
update the config set help/docs example to show the inferred settings-type path
instead of forcing `--type list`.

Tests:
- mise run test:e2e e2e/cli/test_config_set e2e/cli/test_settings_set
@KrishRVH
KrishRVH force-pushed the fix/config-set-preserve-set-values branch from 03a9309 to 721d6c9 Compare July 1, 2026 15:44
@KrishRVH

KrishRVH commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@KrishRVH

KrishRVH commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Reviews resumed.

@jdx
jdx merged commit b17239e into jdx:main Jul 1, 2026
32 of 34 checks passed
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.

2 participants