Skip to content

fix(config): persist API URL override#44

Closed
tkkhq wants to merge 1 commit into
mainfrom
fix/persist-api-url-config
Closed

fix(config): persist API URL override#44
tkkhq wants to merge 1 commit into
mainfrom
fix/persist-api-url-config

Conversation

@tkkhq

@tkkhq tkkhq commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • persist api_url in ~/.volcano/config.json
  • resolve API URL with precedence: VOLCANO_API_URL → runtime override → persisted config → compiled default
  • retain environment-variable precedence for explicit dev/staging invocations

Validation

  • go test ./...

@tkkhq tkkhq requested a review from a team as a code owner July 10, 2026 15:13
Copilot AI review requested due to automatic review settings July 10, 2026 15:13

Copilot AI 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.

Pull request overview

This PR updates the CLI configuration model so an installer-selected API endpoint can be persisted in ~/.volcano/config.json, while still allowing process-level overrides via VOLCANO_API_URL and runtime overrides.

Changes:

  • Added a persisted api_url field (ConfiguredAPIURL) to the on-disk config model.
  • Updated Config.APIURL() to resolve API URL with precedence: env → runtime override → persisted config → compiled default.
  • Updated/added tests to verify persistence and precedence behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
internal/config/config.go Adds a persisted API URL field and updates URL resolution precedence.
internal/config/config_test.go Updates persistence tests and adds precedence coverage for the new field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/config/config.go
Comment on lines +43 to +45
// APIBaseURL overrides the configured API URL for synthetic command configs.
// It is intentionally not persisted to the user's cloud config file.
APIBaseURL string `json:"-"`
UserToken string `json:"user_token,omitempty"`
UserID string `json:"user_id,omitempty"`
AnonKey string `json:"-"`
ServiceKey string `json:"-"`
CurrentProject *ProjectConfig `json:"current_project,omitempty"`
APIBaseURL string `json:"-"`
Comment thread internal/config/config.go
Comment on lines 193 to 195
if c.APIBaseURL != "" {
return c.APIBaseURL
}
require.NoError(t, err)
assert.NotContains(t, string(data), "api_url")
assert.NotContains(t, string(data), "http://localhost:8000")
assert.Contains(t, string(data), `"api_url": "http://configured.example.test"`)

@swkeever swkeever left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Small, well-tested fix — precedence logic and round-trip behavior are covered by the new tests, gofmt/go vet/go test ./internal/config/... all pass. One non-blocking question inline.

Comment thread internal/config/config.go
CurrentProject *ProjectConfig `json:"current_project,omitempty"`
APIBaseURL string `json:"-"`
// ConfiguredAPIURL is the durable API endpoint selected by the installer.
// VOLCANO_API_URL remains the higher-precedence, per-process override.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nothing in this repo currently writes ConfiguredAPIURLcfg.Save() call sites (auth.go, function.go, project.go) never set it, so today this only round-trips a value that was placed into config.json by an external process (per the comment, "selected by the installer"). Worth confirming that installer path actually exists/is landing separately, since right now there's no way for a user to get this field populated (short of hand-editing the file) and exercise the new precedence.

@tkkhq

tkkhq commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing as unnecessary scope expansion. End users use the CLI compiled production API URL and do not configure API endpoints. VOLCANO_API_URL remains an explicit process-level developer/maintainer override; installers will not persist or mutate API URL configuration.

@tkkhq tkkhq closed this Jul 10, 2026
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.

4 participants