Skip to content

Conversation

@ourines
Copy link
Owner

@ourines ourines commented Feb 10, 2026

Summary

  • Add backward-compatible config migration via custom UnmarshalJSON — old flat-field configs are auto-migrated to the new env map format
  • Fix JSON injection in TestAPIConfig by replacing fmt.Sprintf with json.Marshal
  • Fix format string bugs in RunConfigSet/RunConfigGet where %s was never substituted
  • Remove unused cfg parameter from SetEnvironmentVarsWithConfig
  • Fix import ordering in cobra.go
  • Replace log.Printf with fmt.Fprintf for consistent logging style

Test plan

  • Verify old-format config.json loads correctly and env vars are migrated
  • Verify codes test works with model names containing special characters
  • Verify codes config get invalidkey shows the key name in error message
  • Verify go build ./... passes

Fixes #4, Fixes #5, Fixes #6

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores

    • Refactored environment-variable/config handling for clearer behavior and maintainability.
    • Added automatic migration of legacy configuration fields so older configs continue to work.
  • Bug Fixes

    • Standardized error messaging for unknown configuration keys.
    • Improved how external processes are launched so commands run in the intended directory.

@coderabbitai
Copy link

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

Adds JSON unmarshaling to migrate legacy flat API config fields into the new env map, fixes JSON-building and format-string bugs, removes an unused parameter from SetEnvironmentVarsWithConfig and updates its call sites, and adjusts import/logging ordering.

Changes

Cohort / File(s) Summary
Config migration & env handling
internal/config/config.go
Added UnmarshalJSON to detect/migrate legacy ANTHROPIC_BASE_URL/ANTHROPIC_AUTH_TOKEN into Env; replaced string-based test request construction with structured types + json.Marshal; removed log usage in favor of fmt.Fprintf(os.Stderr, ...); adjusted imports.
Command callsites & error formatting
internal/commands/commands.go
Updated SetEnvironmentVarsWithConfig call sites to the new single-arg signature; changed process invocation to set cmd.Dir = dir; fixed format-string usage by constructing error messages with fmt.Sprintf before passing to ui.ShowError.
Import ordering
internal/commands/cobra.go
Reordered standard-library imports (moved strings into stdlib group) to satisfy usage in SkipPermissionsSetCmd (no functional change).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐇 I nibbled through old JSON lines,
Pulled tokens from forgotten mines,
Cleaned the strings and tuned the flow,
Pruned a param — now onward we go,
The warren hums with brighter signs.

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% 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 'fix: address issues from PR #2 merge' clearly summarizes the main focus of the pull request, which consolidates fixes for three specific issues identified after PR #2.
Linked Issues check ✅ Passed All coding requirements from linked issues #4, #5, and #6 are met: custom UnmarshalJSON for config migration, JSON injection fix via json.Marshal, format string fixes, unused parameter removal, import ordering correction, and logging style alignment.
Out of Scope Changes check ✅ Passed All changes directly address the three linked issues without introducing unrelated modifications. Changes are confined to fixing the identified problems in cobra.go, commands.go, and config.go.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/pr2-issues

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

@ourines
Copy link
Owner Author

ourines commented Feb 10, 2026

@copilot

Copy link

Copilot AI commented Feb 10, 2026

@ourines I've opened a new pull request, #8, to work on those changes. Once the pull request is ready, I'll request review from you.

- Add backward-compatible config migration via custom UnmarshalJSON,
  so old flat-field configs (ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN)
  are automatically migrated to the new env map format
- Fix JSON injection in TestAPIConfig by using json.Marshal instead of
  fmt.Sprintf for building the request body
- Fix format string bugs in RunConfigSet/RunConfigGet where %s was
  never substituted in ui.ShowError calls
- Remove unused cfg parameter from SetEnvironmentVarsWithConfig
- Fix import ordering in cobra.go
- Replace log.Printf with fmt.Fprintf for consistent logging style

Fixes #4, Fixes #5, Fixes #6
@ourines ourines merged commit 5918b74 into main Feb 10, 2026
2 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

2 participants