Skip to content

airflowctl auth login fails when --api-url ends with trailing slash #61244

@emin-ozata

Description

@emin-ozata

Apache Airflow version

3.1.6

If "Other Airflow 3 version" selected, which one?

No response

What happened?

When copying the Airflow base URL from the browser address bar, it typically includes a trailing slash by default.

Using this URL directly with airflowctl auth login causes the client to construct the auth endpoint with a double slash (//auth), which results in a failed authentication request.

airflow/airflow-ctl/src/airflowctl/api/client.py

#@classmethod
def _get_base_url(
    cls, base_url: str, kind: Literal[ClientKind.AUTH, ClientKind.CLI] = ClientKind.CLI
) -> str:
    """Get the base URL of the client."""
    if kind == ClientKind.AUTH:
        return f"{base_url}/auth"
    return f"{base_url}/api/v2"

What you think should happen instead?

No response

How to reproduce

Run airflowctl auth login with an --api-url value that ends with a trailing slash (/).

airflowctl auth login \
  --username airflow \
  --password airlfow \
  --api-url http://localhost:8080/
2026-01-30 11:21:20 [warning  ] Server error                   [airflowctl.api.client] extra={'detail': 'Method Not Allowed'}
Login failed: Client error message: {'detail': 'Method Not Allowed'}

Operating System

Darwin Kernel Version 25.2.0

Versions of Apache Airflow Providers

No response

Deployment

Official Apache Airflow Helm Chart

Deployment details

No response

Anything else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions