Repository navigation
fix(cli): quote cobra defaults that KDL reads as booleans or numbers - #1595
Conversation
The Cobra exporter wrote some flag defaults as bare KDL values, so
`Bool("enabled", true)` produced `default=true` and `Int("parallel", -1)`
produced `default=-1`. Usage expects string defaults, so `usage lint`
rejected the generated spec.
needsQuoting now also quotes true/false/null/inf/-inf/nan, signed
numbers, and values containing brackets.
Fixes #1594
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Entire-Checkpoint: 01M64MA2XS7BMFE1WFRFEAW1M3
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Quote non-identifier defaults integrations/cobra/kdl.go, integrations/cobra/cobra_usage_test.go |
needsQuoting now quotes signed numeric-looking values, KDL keywords, and values containing square brackets. The test checks quoted defaults for representative boolean, numeric, null-like, and bracketed values. |
Priority:
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Suggested reviewers: thecodesmith
Merge Risk: 
Minimal · up to 920d2
-
No actionable merge-blocking risk was identified in the changed default-quoting behavior.
Pre-merge checks: 
5
-
Full details: Linked Issues check
-
Explanation
Issue
#1594requires Cobra defaults such as booleantrueand negative integer-1to remain KDL strings. At the reviewed head,renderFlagpasses single defaults throughkdlQuote, andneedsQuotingquotestrue, signed numeric values, and other KDL-sensitive values.TestDefaultsQuotedWhenNotIdentifiersverifiesdefault="true",default="-1", and related cases. The existingjsoncase remains bare inTestDefaultValues.
Full details: Out of Scope Changes check
-
Explanation
The reviewed changes are limited to KDL quoting behavior in
integrations/cobra/kdl.goand focused Cobra exporter tests inintegrations/cobra/cobra_usage_test.go. The added bracket, keyword, and signed-number checks support valid string serialization for the linked issue. No unrelated change is evidenced.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Comment @coderabbitai help to get the list of available commands.
[Low impact] The PR appears safe to merge. SummaryThe Cobra exporter now quotes defaults that cannot safely appear as bare KDL strings.
Reviews (1) · Last reviewed commit: "fix(cli): quote cobra defaults that KDL ..." · Reviewed by Greptile |
Instruction counts
No instruction-count regression above 1%. Only instruction counts gate. Wall clock is shown for context — on identical hardware it moves 4-20% run to run. Measured by tak — instruction-counted CLI benchmarks, stored in this repository's git notes. Shadow comparisonParsing
|
### 🐛 Bug Fixes - **(cli)** quote cobra defaults that KDL reads as booleans or numbers by [@jdx](https://github.com/jdx) in [#1595](#1595) - **(lib)** read a mounted script's spec despite a rejected env value, and name the failing mount by [@jdx](https://github.com/jdx) in [#1591](#1591) ### 🛡️ Security - **(deps)** update jdx/packslip action to v1.11.0 by [@renovate[bot]](https://github.com/renovate[bot]) in [#1597](#1597) ### 📦️ Dependency Updates - update github actions by [@renovate[bot]](https://github.com/renovate[bot]) in [#1585](#1585) - update mise tools by [@renovate[bot]](https://github.com/renovate[bot]) in [#1586](#1586) - update dependency @types/node to v26 by [@renovate[bot]](https://github.com/renovate[bot]) in [#1587](#1587) - lock file maintenance by [@renovate[bot]](https://github.com/renovate[bot]) in [#1588](#1588) - update mise tools to latest by [@renovate[bot]](https://github.com/renovate[bot]) in [#1592](#1592) - lock file maintenance by [@renovate[bot]](https://github.com/renovate[bot]) in [#1593](#1593) - update dependency effect to v4.0.6 by [@renovate[bot]](https://github.com/renovate[bot]) in [#1596](#1596)
The Cobra exporter wrote some flag defaults as bare KDL values, which usage rejects because defaults must be strings. A Cobra command with a
truebool flag or a negative integer flag produced a spec thatusage lintcould not parse.Before
usage lintfailed with "Expected identifier string" and "expected string".After
The cause was
needsQuotinginintegrations/cobra/kdl.go, which only quoted values starting with a digit or containing certain punctuation. It now also quotes:true,false,null,inf,-inf,nan-1,+1and-0.5[or]Plain values such as
jsonare still emitted bare, so existing output is unchanged.Validation: a new Go test covers each case. I also generated a spec containing these defaults and ran it through
usage lintfrom usage 7.1.3, which reported 0 errors. That round trip was a one-off check, not part of the test suite.Fixes #1594
AI-assisted — Tool: Claude Code; model: anthropic/claude-sonnet-5-5; version: unavailable.
🤖 Generated with Claude Code
Summary by CodeRabbit
"+1","null", and"[a]"from being interpreted as something other than their intended text.