Skip to content

fix: describe reads the configured API endpoint - #24

Merged
jeroenrinzema merged 1 commit into
mainfrom
fix/describe-endpoint
Nov 15, 2026
Merged

jeroenrinzema merged 1 commit into
mainfrom
fix/describe-endpoint

Conversation

@jeroenrinzema

Copy link
Copy Markdown
Collaborator

brainpod describe resource … only passed --endpoint to the OpenAPI fetch. It ignored BRAINPOD_API_ENDPOINT and the configured endpoint, so agent runners pointed at a local or test installation were described with production's schema (OpenAPI: https://api.brainpod.io/v1/openapi.json).

  • Adds api_endpoint (flag → BRAINPOD_API_ENDPOINT → config endpoint → default), shared by describe and the other commands. Describe loads the config only when neither the flag nor the env var is set, and it still needs no token. BRAINPOD_OPENAPI_URL still takes precedence.
  • Adds a unit test for the precedence, including that the env var is used without loading the config.
  • Updates the README.

@jeroenrinzema
jeroenrinzema requested a balanced review from Copilot November 15, 2026 19:21

@dmeijboom dmeijboom 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.

LGTM

@jeroenrinzema
jeroenrinzema added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit a4bd038 Nov 15, 2026
7 checks passed

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.

🟡 Changes recommended

Without endpoint overrides, an explicit BRAINPOD_OPENAPI_URL now unnecessarily triggers config loading, causing describe resource … to fail when configuration is unreadable or malformed.

1 open issue
What changed in this PR

This PR makes resource descriptions use the configured API endpoint, aligning schema discovery with other CLI commands while keeping it token-free.

Changes:

  • Shares endpoint resolution with precedence: flag → environment → config → default.
  • Adds unit coverage for precedence and skipping config loading when an environment override is supplied.
  • Documents endpoint selection and the OpenAPI URL override.
File Description
src/​main.rs Adds shared endpoint resolution, uses it for resource descriptions, and tests precedence.
README.md Documents schema URL resolution and token-free access.

Review effort: Balanced

Comment thread src/main.rs
Comment on lines +108 to +113
let endpoint = api_endpoint(
opts.endpoint.clone(),
environment("BRAINPOD_API_ENDPOINT"),
|| Ok(Config::load(&Config::path()?)?.endpoint),
)?;
let resource_description = openapi::describe(&args.command, Some(&endpoint)).await?;
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.

3 participants