Skip to content

config: add macro support for name and description fields#578

Merged
mostlygeek merged 1 commit intomainfrom
claude/add-config-macros-gYUF3
Mar 10, 2026
Merged

config: add macro support for name and description fields#578
mostlygeek merged 1 commit intomainfrom
claude/add-config-macros-gYUF3

Conversation

@mostlygeek
Copy link
Owner

Extend macro substitution to the name and description fields of
ModelConfig, matching the behavior already present for cmd, proxy,
checkEndpoint, and filters.

  • substitute global/model macros (including MODEL_ID) in name and description
  • substitute PORT macro in name and description when allocated
  • validate no unknown macros remain in name and description after substitution
  • add tests for macro substitution, MODEL_ID, and unknown macro error

Extend macro substitution to the name and description fields of
ModelConfig, matching the behavior already present for cmd, proxy,
checkEndpoint, and filters.

- substitute global/model macros (including MODEL_ID) in name and description
- substitute PORT macro in name and description when allocated
- validate no unknown macros remain in name and description after substitution
- add tests for macro substitution, MODEL_ID, and unknown macro error
@coderabbitai
Copy link

coderabbitai bot commented Mar 10, 2026

Walkthrough

The PR adds Name and Description fields to the ModelConfig struct and extends macro substitution logic to apply replacements to these new fields during model-level macro processing across multiple substitution passes and validation workflows.

Changes

Cohort / File(s) Summary
Model Configuration
proxy/config/config.go
Added Name and Description fields to ModelConfig struct; extended macro substitution to process these fields in per-macro substitution loops, PORT macro substitution paths, and field validation maps.
Test Coverage
proxy/config/macro_in_macro_test.go
Added three test functions: TestConfig_MacroInNameAndDescription, TestConfig_ModelIDInNameAndDescription, and TestConfig_UnknownMacroInNameDescription to validate macro substitutions in name/description fields and error handling for undefined macros.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested labels

enhancement, configuration

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: extending macro support to name and description fields in the config.
Description check ✅ Passed The description clearly explains the purpose and specific implementation details of extending macro substitution to name and description fields.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch claude/add-config-macros-gYUF3

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
proxy/config/config.go (1)

343-358: Consider adding a clearer error message for ${PORT} usage in name/description without cmd.

If a user specifies ${PORT} in name or description but not in cmd, the PORT macro won't be substituted (this block is skipped), and validation will produce "macro '${PORT}' should have been substituted" which is slightly confusing.

Consider checking for this edge case explicitly for a more helpful error message:

💡 Optional improvement for clearer error messaging
 		// Handle PORT macro - only allocate if cmd uses it
 		cmdHasPort := strings.Contains(modelConfig.Cmd, "${PORT}")
 		proxyHasPort := strings.Contains(modelConfig.Proxy, "${PORT}")
+		nameHasPort := strings.Contains(modelConfig.Name, "${PORT}")
+		descHasPort := strings.Contains(modelConfig.Description, "${PORT}")
+
+		if (nameHasPort || descHasPort) && !cmdHasPort {
+			return Config{}, fmt.Errorf("model %s: name/description uses ${PORT} but cmd does not - ${PORT} is only available when used in cmd", modelId)
+		}
+
 		if cmdHasPort || proxyHasPort {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@proxy/config/config.go` around lines 343 - 358, Detect when the ${PORT} macro
appears in modelConfig.Name or modelConfig.Description while modelConfig.Cmd
does not contain ${PORT} (same situation already checked for modelConfig.Proxy)
and return a clear error (e.g., "model %s: ${PORT} found in name/description but
cmd does not contain ${PORT} — ${PORT} is only substituted when used in cmd").
Update the existing macro handling block that checks cmdHasPort/proxyHasPort to
also inspect Name and Description for "${PORT}" and produce this explicit error
referencing modelId, modelConfig.Name, modelConfig.Description, and
modelConfig.Cmd so it's easy to locate and fix in the code.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@proxy/config/config.go`:
- Around line 343-358: Detect when the ${PORT} macro appears in modelConfig.Name
or modelConfig.Description while modelConfig.Cmd does not contain ${PORT} (same
situation already checked for modelConfig.Proxy) and return a clear error (e.g.,
"model %s: ${PORT} found in name/description but cmd does not contain ${PORT} —
${PORT} is only substituted when used in cmd"). Update the existing macro
handling block that checks cmdHasPort/proxyHasPort to also inspect Name and
Description for "${PORT}" and produce this explicit error referencing modelId,
modelConfig.Name, modelConfig.Description, and modelConfig.Cmd so it's easy to
locate and fix in the code.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 58b553d5-a21f-4869-97af-c78921bffc53

📥 Commits

Reviewing files that changed from the base of the PR and between cc77139 and f117112.

📒 Files selected for processing (2)
  • proxy/config/config.go
  • proxy/config/macro_in_macro_test.go

@mostlygeek mostlygeek merged commit 24efdb7 into main Mar 10, 2026
3 checks passed
@mostlygeek mostlygeek deleted the claude/add-config-macros-gYUF3 branch March 10, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants