Skip to content

Python CLI config edits discard unknown top-level settings #12978

Closed

Description

@ikoomm

Update: submitted PR #12990 with the fix, regression test, and README clarification. Full CLI suite now passes in a single run: 130 tests. Repository preflight reports 12 selected checks passed on the committed diff; the 90-day failure-class recurrence check explicitly skips for a shallow clone and needs full-history CI. The earlier sparse-checkout limitation below describes the initial investigation. Bounty approval remains pending.
On main 7163538913e15dd86534b41dc695e2a5639c0774, omi config set discards unknown top-level settings from config.toml. The configuration module documents preservation of unknown keys for forward compatibility, and already implements it inside profiles, but load() drops root-level extensions before save() rewrites the file.

For example, start with this synthetic configuration (no credentials):

active_profile = "default"
future_flag = true
[future_display]
language = "ar"
[profiles.default]
api_base = "https://api.omi.me"

Run omi config set api_base https://example.test with OMI_CONFIG pointing to that file. The API base changes successfully, but both future_flag and future_display disappear. These are illustrative extension names, not a claim that a currently released client writes those fields. The issue concerns the documented round-trip contract.

I reproduced this through the real registered CLI command using the repository's CliRunner and isolated temporary configuration fixture on Windows/Python 3.12. The regression test fails with KeyError: 'future_flag' before the candidate below and passes afterward. No service calls or real account data are involved.

The candidate preserves root extras, with authoritative known fields taking precedence when saving:

 class Config:
     path: Path
     active_profile: str = DEFAULT_PROFILE_NAME
     profiles: dict[str, Profile] = field(default_factory=dict)
+    extra: dict[str, Any] = field(default_factory=dict)

-    return Config(path=p, active_profile=active, profiles=profiles)
+    extra = {key: value for key, value in data.items() if key not in {"active_profile", "profiles"}}
+    return Config(path=p, active_profile=active, profiles=profiles, extra=extra)

     payload: dict[str, Any] = {
+        **config.extra,
         "active_profile": config.active_profile,
         "profiles": {name: p.to_toml_dict() for name, p in config.profiles.items()},
     }

The regression invokes config set, reparses the resulting TOML, and checks the changed API base plus preservation of both scalar and nested unknown settings. All 16 configuration tests pass. Black, isort, mypy on config.py, and git diff --check pass. The 130-test component run had 126 passes and four failures caused by the sparse checkout omitting docs/api-reference/openapi.json; after restoring that source directory, all four affected tests passed on rerun. This is aggregate verification, not a claim of one clean full-suite run. This is a tested candidate, not a merge-ready PR: repository preflight encounters missing cross-component artifacts in this sparse checkout, so I am not claiming that gate passed.

Following the contribution guide's invitation to suggest paid work: @josancamon19, would this focused fix, regression test, and documentation clarification qualify for US$5 via the documented PayPal process after acceptance and merge? I can receive PayPal payments in Saudi Arabia. This contribution is AI-assisted on behalf of @ikoomm. No bounty approval, assignment, or payment is assumed, and payment details will stay private.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions