Skip to content

fix: use active env for auth login#26

Merged
jpage-godaddy merged 2 commits into
mainfrom
codex/auth-env-default-main
Jun 16, 2026
Merged

fix: use active env for auth login#26
jpage-godaddy merged 2 commits into
mainfrom
codex/auth-env-default-main

Conversation

@jbrooks2-godaddy

@jbrooks2-godaddy jbrooks2-godaddy commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Make built-in auth login/logout accept the active middleware env when --env is omitted
  • Keep explicit --env as an override
  • Add regression tests for consumer-style global env defaults

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 built-in runtime auth login/auth logout commands to default their target environment from the active middleware environment when --env is not provided, while keeping an explicitly provided --env as an override. It also adds regression tests and updates documentation to reflect the new optional --env behavior.

Changes:

  • Make auth login and auth logout accept omitted --env and resolve the environment from middleware state.
  • Add regression tests covering middleware default env behavior and explicit --env override.
  • Update auth command docs to document --env as optional for login/logout.

Reviewed changes

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

File Description
tests/foundation.rs Adds tests for env resolution behavior and adjusts command-spec assertions for optional --env.
src/auth/commands.rs Makes --env optional for login/logout and adds env resolution helper with a runtime error when missing.
docs/auth.md Updates built-in auth command documentation to reflect optional --env semantics for login/logout.

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

Comment thread src/auth/commands.rs
Comment on lines +122 to +135
fn env_arg(context: &CommandContext) -> Result<String> {
let env = string_arg(&context.args, "env");
if !env.is_empty() {
return Ok(env);
}

if !context.middleware.env.is_empty() {
return Ok(context.middleware.env.clone());
}

Err(CliCoreError::message(
"auth: missing environment; pass --env or configure a default environment",
))
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 8fc6485: env resolution now checks command-level user_args first, rejects explicit empty --env, then falls back to middleware.env. See src/auth/commands.rs:122.

Comment thread tests/foundation.rs
json!({"provider": "primary", "env": "dev", "status": "logged out"})
);
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 8fc6485: added JSON error-path coverage for missing env and explicit empty env, plus logout explicit override coverage. See tests/foundation.rs:2414, tests/foundation.rs:2430, and tests/foundation.rs:2462.

@jpage-godaddy jpage-godaddy 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.

Thanks! This was bothering me too.

@jpage-godaddy jpage-godaddy merged commit ba1711e into main Jun 16, 2026
3 checks passed
@jpage-godaddy jpage-godaddy deleted the codex/auth-env-default-main branch June 16, 2026 00:44

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

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

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