Skip to content

fix(pathmeta): quote string attributes that look like numbers when saving vfox.toml - #756

Merged
linghengqian merged 1 commit into
version-fox:mainfrom
Saadanjum0:fix/quote-numeric-looking-attrs
Nov 13, 2026
Merged

linghengqian merged 1 commit into
version-fox:mainfrom
Saadanjum0:fix/quote-numeric-looking-attrs

Conversation

@Saadanjum0

Copy link
Copy Markdown
Contributor

Problem

Tool attributes in .vfox.toml are strings, but when the file is saved some of them are written as bare TOML values and read back as something else:

  • dist = "17.0" is saved as dist = 17.0 and reloaded as "17"
  • "1.50" becomes "1.5", "1e3" becomes "1000", "+5" becomes "5", "nan" becomes "NaN"
  • "007" is saved as dist = 007, which is invalid TOML, so the file can no longer be loaded

Any command that loads and re-saves the config (for example vfox use for another SDK) rewrites the other tools' attributes this way.

Cause

formatAttributeValue in internal/pathmeta/vfox_toml.go wrote a value bare whenever strconv.ParseInt or strconv.ParseFloat accepted it. Those accept more than TOML does (leading zeros, +, _, nan, inf) and do not preserve the original text.

Fix

Write only true/false and canonical integers (value equals FormatInt(ParseInt(value))) bare; quote everything else. The float branch is dropped, since a float cannot be reproduced as the same string.

Testing

  • Added TestVfoxToml_StringAttrRoundTrip, which saves and reloads attributes such as 17.0, 1.50, 007, 1e3, 1_000, +5, nan, inf. It fails before the change and passes after.
  • go test ./... passes.

Copilot AI balanced review requested due to automatic review settings November 12, 2026 11:47

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@codecov

codecov Bot commented Nov 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.26%. Comparing base (1446db1) to head (711a6a4).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #756      +/-   ##
==========================================
+ Coverage   56.21%   56.26%   +0.04%     
==========================================
  Files         115      115              
  Lines        8576     8574       -2     
==========================================
+ Hits         4821     4824       +3     
+ Misses       3291     3287       -4     
+ Partials      464      463       -1     

☔ 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.

@linghengqian linghengqian added the bug Something isn't working label Nov 13, 2026

@linghengqian linghengqian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@linghengqian linghengqian added this to the 1.1.1 milestone Nov 13, 2026
@linghengqian
linghengqian merged commit 1635ffd into version-fox:main Nov 13, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants