Skip to content

fix(cli): store config set values for string keys verbatim - #2522

Open
acodercat wants to merge 4 commits into
opensandbox-group:mainfrom
acodercat:fix/cli-config-set-keeps-number-text
Open

acodercat wants to merge 4 commits into
opensandbox-group:mainfrom
acodercat:fix/cli-config-set-keeps-number-text

Conversation

@acodercat

@acodercat acodercat commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

osb config set infers the TOML type of every value: true/false become booleans, and anything that int() or float() accepts becomes a number. The resolver turns numbers back into strings for string keys such as connection.api_key, as its docstring describes for all-digit keys. But by then the text has already changed:

  • osb config set connection.api_key 007123 writes api_key = 7123, and the CLI authenticates with 7123.
  • 1e10 is written as 10000000000.0, NaN as nan, 1_000 as 1000, and 1.50 as 1.5.

So a key or other string value that happens to look like a number is silently replaced with a different one.

Summary

  • opensandbox_cli.config lists the keys resolve_config reads as text in STRING_KEYS: connection.api_key, connection.domain, connection.protocol, defaults.image and defaults.timeout.
  • config set stores values for those keys verbatim, as strings.
  • Every other key keeps the existing type inference unchanged. request_timeout, use_server_proxy and color are still written as numbers or booleans, so spellings like 1e2 or 1.00 still resolve as before.

Testing

  • Not run (explain why)

  • Unit tests

  • Integration tests

  • e2e / manual verification

  • New test_set_keeps_text_a_number_would_change for 007123, 1e10, NaN, 1_000 and 1.50: the stored and the resolved api_key must equal the typed text. Every case fails on current main.

  • New test_set_still_infers_numbers_for_typed_keys: request_timeout 1e2 must resolve to 100 and use_server_proxy 1.00 to True. Storing every value as text fails it.

  • The existing test_set_infers_scalar_types still passes. The full CLI suite passes (337 passed), and ruff and pyright are clean.

Breaking Changes

  • None
  • Yes (describe impact and migration path)

Checklist

  • Linked Issue or clearly described motivation
  • Added/updated docs (if needed)
  • Added/updated tests (if needed)
  • Security impact considered
  • Backward compatibility considered

`osb config set` stores anything that parses as an int or a float as a
TOML number. For string keys that changed the value: an API key
`007123` was written as `7123`, `1e10` as `10000000000.0` and `NaN` as
`nan`, and the resolver then used the changed text, so authentication
silently used the wrong key.

Use a number only when it writes back as the same text, and store the
value as a string otherwise. `45`, `1.5` and `true` keep their native
types as before.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-31T10:10:34.310423Z 4f1b78a Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Oct 31, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e5b243d25

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

number = parse(raw)
except ValueError:
continue
return number if str(number) == raw else raw

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve noncanonical numeric forms for typed settings

When this generic helper is used for a typed setting, numeric spellings that Python normalizes are now quoted. For example, osb config set connection.request_timeout 1e2 used to write a float that resolve_config coerced to 100, but now writes "1e2"; _int_or_none cannot parse that string and silently falls back to 30. Likewise, connection.use_server_proxy 1.00 now resolves to False instead of True, despite numeric scalar coercion being explicitly covered in cli/tests/test_config.py:162-173. Preserve raw text only for string-valued keys, or continue accepting these quoted numeric forms in the typed coercers.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, thanks. Fixed in 4f1b78a by going the first way: _parse_toml_value is back to its original inference, and config set stores the value verbatim only for the keys resolve_config reads as text. Those keys are listed once, as STRING_KEYS next to resolve_config: api_key, domain, protocol, defaults.image and defaults.timeout. request_timeout 1e2 resolves to 100 again and use_server_proxy 1.00 to True, and both are covered by test_set_still_infers_numbers_for_typed_keys.

…rest

The round-trip rule also quoted noncanonical numbers for typed keys:
`config set connection.request_timeout 1e2` was written as "1e2", which
the resolver cannot parse, so it fell back to 30, and
`connection.use_server_proxy 1.00` resolved to False.

Store values verbatim only for the keys resolve_config reads as text
(api_key, domain, protocol, defaults.image, defaults.timeout), and keep
the original type inference for every other key.
@acodercat acodercat changed the title fix(cli): keep config set values that a number would rewrite fix(cli): store config set values for string keys as typed Oct 31, 2026
@acodercat

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: 4f1b78ac32

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@acodercat acodercat changed the title fix(cli): store config set values for string keys as typed fix(cli): store config set values for string keys verbatim Oct 31, 2026

This branch has not been deployed

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

Labels

size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant