Skip to content

fix: raise error when auth login remote URL is missing - #3

Closed
euxaristia wants to merge 1 commit into
mainfrom
fix-auth-login-silent-failure
Closed

fix: raise error when auth login remote URL is missing#3
euxaristia wants to merge 1 commit into
mainfrom
fix-auth-login-silent-failure

Conversation

@euxaristia

@euxaristia euxaristia commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Avoid a silent/hanging failure when running lore auth login without a remote URL argument or configured repository remote.

  • Add CLI-side validation in lore-client/src/cli/commands/auth.rs.
  • Add matching library-side guard in lore/src/auth.rs for non-interactive login paths.
  • Add unit tests covering interactive/token login remote resolution.

Summary by CodeRabbit

  • Bug Fixes
    • Improved login handling when a repository remote is missing or not configured.
    • Login now uses the provided remote URL when available, and supports token-based login with an explicit authentication URL.
    • Added clearer failure handling for login attempts that don’t have a valid remote.
    • Tightened validation so token and interactive login flows behave more consistently.

Avoid a silent/hanging failure when running 'lore auth login' without a remote URL argument or configured repository remote.

Add CLI-side validation and comprehensive unit tests to ensure a clear error is printed to the user.

Signed-off-by: euxaristia <euxaristia@users.noreply.github.com>
@euxaristia euxaristia added the bug Something isn't working label Jun 28, 2026
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a LOGIN_REMOTE_REQUIRED error constant and a resolve_login_remote_url helper in the CLI layer that resolves the login remote from CLI args, repo config, or auth-url fallback. The library's login_with_token_local and login_interactive_local functions gain early empty-remote guards returning the same error. Unit tests cover the three resolution cases.

Login Remote URL Resolution and Validation

Layer / File(s) Summary
Remote URL resolution helpers and CLI integration
lore-client/src/cli/commands/auth.rs
Adds LOGIN_REMOTE_REQUIRED constant, configured_remote_url, login_with_token_can_use_explicit_auth_url, and resolve_login_remote_url helpers; updates handle_login_command to call resolve_login_remote_url with early exit on failure and consolidates --token-type/--token XOR validation.
Early remote guards in library login functions
lore/src/auth.rs
Adds LOGIN_REMOTE_REQUIRED constant and InteractiveLoginError import; refactors login_with_token_local and login_interactive_local scoped async blocks to return the new error immediately when remote_url is empty.
Unit tests for resolve_login_remote_url
lore-client/src/cli/commands/auth.rs
Three tests: errors with LOGIN_REMOTE_REQUIRED when no remote available, allows empty remote for token login with explicit --auth-url, and returns the explicit --remote-url when provided.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 No remote, no entry, the warren is clear,
A URL missing? We halt right here.
resolve_login_remote_url hops down the chain,
Token or interactive — none shall complain.
The tests all pass and the burrow is tight! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.00% 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 clearly summarizes the main change: adding an error when auth login lacks a remote URL.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-auth-login-silent-failure

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lore-client/src/cli/commands/auth.rs`:
- Line 41: The LOGIN_REMOTE_REQUIRED message in auth.rs should include the
token-login fallback so users without a remote know the valid remediation.
Update the error path used by the auth command, including the logic around the
token-login branch in the authenticate flow, to mention `--auth-url` alongside
the existing remote URL or repository remote guidance. Make sure the message
still fits both the normal login path and the `--token-type`/`--token` path
handled by the auth command’s login/authentication code.

In `@lore/src/auth.rs`:
- Line 33: The shared missing-remote message in auth handling is too generic for
the guard that accepts either remote_url or auth_url. Update the token-related
branch in lore/src/auth.rs to use a token-specific missing-endpoint message
instead of LOGIN_REMOTE_REQUIRED, so callers are told auth_url is also an
acceptable fix; keep the same behavior for the existing remote URL path and
adjust the other referenced occurrence as well.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ec81e558-add1-4197-86ed-7b6827d792d1

📥 Commits

Reviewing files that changed from the base of the PR and between 4bffa76 and bde655c.

📒 Files selected for processing (2)
  • lore-client/src/cli/commands/auth.rs
  • lore/src/auth.rs

use crate::styling::CommonStyles;
use crate::util;

const LOGIN_REMOTE_REQUIRED: &str = "No remote URL supplied. Run `lore auth login <remote-url>` or run from a Lore repository with a configured remote.";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Include the token-login --auth-url remediation in this error path.

Lines 149-150 intentionally allow token login without a remote when explicit --auth-url is present, but Line 41 only tells users to provide a remote URL or repo config. For --token-type/--token users missing --auth-url, the error omits a valid fix.

Suggested adjustment
 const LOGIN_REMOTE_REQUIRED: &str = "No remote URL supplied. Run `lore auth login <remote-url>` or run from a Lore repository with a configured remote.";
+const LOGIN_TOKEN_REMOTE_OR_AUTH_URL_REQUIRED: &str =
+    "No remote URL or auth URL supplied. Run `lore auth login <remote-url>` or pass `--auth-url` for token login outside a Lore repository.";
@@
-    Err(LOGIN_REMOTE_REQUIRED)
+    if args.token_type.is_some() && args.token.is_some() {
+        Err(LOGIN_TOKEN_REMOTE_OR_AUTH_URL_REQUIRED)
+    } else {
+        Err(LOGIN_REMOTE_REQUIRED)
+    }

Also applies to: 149-153

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lore-client/src/cli/commands/auth.rs` at line 41, The LOGIN_REMOTE_REQUIRED
message in auth.rs should include the token-login fallback so users without a
remote know the valid remediation. Update the error path used by the auth
command, including the logic around the token-login branch in the authenticate
flow, to mention `--auth-url` alongside the existing remote URL or repository
remote guidance. Make sure the message still fits both the normal login path and
the `--token-type`/`--token` path handled by the auth command’s
login/authentication code.

Comment thread lore/src/auth.rs
use crate::call_delegation::dispatch_call;
use crate::interface::LoreString;

const LOGIN_REMOTE_REQUIRED: &str = "No remote URL supplied. Run `lore auth login <remote-url>` or run from a Lore repository with a configured remote.";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Use a token-specific missing-endpoint error here.

This guard accepts either remote_url or auth_url, but the shared message only says the remote URL is missing. Return a token-specific message so API/CLI callers know auth_url is also a supported fix.

Suggested adjustment
 const LOGIN_REMOTE_REQUIRED: &str = "No remote URL supplied. Run `lore auth login <remote-url>` or run from a Lore repository with a configured remote.";
+const LOGIN_TOKEN_REMOTE_OR_AUTH_URL_REQUIRED: &str =
+    "No remote URL or auth URL supplied. Provide a remote URL, configured repository remote, or auth_url for token login.";
@@
-                return Err(LoginError::internal(LOGIN_REMOTE_REQUIRED));
+                return Err(LoginError::internal(LOGIN_TOKEN_REMOTE_OR_AUTH_URL_REQUIRED));

Also applies to: 214-215

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lore/src/auth.rs` at line 33, The shared missing-remote message in auth
handling is too generic for the guard that accepts either remote_url or
auth_url. Update the token-related branch in lore/src/auth.rs to use a
token-specific missing-endpoint message instead of LOGIN_REMOTE_REQUIRED, so
callers are told auth_url is also an acceptable fix; keep the same behavior for
the existing remote URL path and adjust the other referenced occurrence as well.

@euxaristia

Copy link
Copy Markdown
Owner Author

Closing in favor of upstream PR EpicGames#84.

@euxaristia euxaristia closed this Jun 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant