Skip to content

CLI add supports for non-http scheme#5043

Merged
MonkeyCanCode merged 7 commits into
apache:mainfrom
MonkeyCanCode:cli_add_scheme_support
Jul 17, 2026
Merged

CLI add supports for non-http scheme#5043
MonkeyCanCode merged 7 commits into
apache:mainfrom
MonkeyCanCode:cli_add_scheme_support

Conversation

@MonkeyCanCode

@MonkeyCanCode MonkeyCanCode commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

This PR fixes #4993 where we default to http for scheme when creating profile. Also, the CLI itself lacks scheme support unless using base_url (so this was not possible earlier when using --host and --port option.

Here is sample output for this change:

Add profiles with http and https scheme:

# https scheme
➜  polaris git:(main) ✗ ./polaris profiles create dev_https
┌─[DEPRECATED]────────────────────────────────┐
│ This script is deprecated. Use pip instead: │
│                                             │
│   pip install apache-polaris                │
└─────────────────────────────────────────────┘
Polaris Client ID: abc
Polaris Client Secret: abc
Polaris Host [localhost]:
Polaris Port [8181]:
Polaris URL Scheme [http]: https
Polaris Context Realm:
Polaris Context Header Name [Polaris-Realm]:
Polaris profile dev_https created successfully.

# http scheme
➜  polaris git:(main) ✗ ./polaris profiles create dev_http
┌─[DEPRECATED]────────────────────────────────┐
│ This script is deprecated. Use pip instead: │
│                                             │
│   pip install apache-polaris                │
└─────────────────────────────────────────────┘
Polaris Client ID: abc
Polaris Client Secret: abc
Polaris Host [localhost]:
Polaris Port [8181]:
Polaris URL Scheme [http]:
Polaris Context Realm:
Polaris Context Header Name [Polaris-Realm]:
Polaris profile dev_http created successfully.

Ensure scheme got persisted:

# display for https scheme
➜  polaris git:(main) ✗ ./polaris profiles get dev_https
┌─[DEPRECATED]────────────────────────────────┐
│ This script is deprecated. Use pip instead: │
│                                             │
│   pip install apache-polaris                │
└─────────────────────────────────────────────┘
Polaris profile dev_https: {'client_id': 'abc', 'client_secret': '********', 'host': 'localhost', 'port': 8181, 'scheme': 'https', 'realm': '', 'header': 'Polaris-Realm'}

# display for http scheme
➜  polaris git:(main) ✗ ./polaris profiles get dev_http
┌─[DEPRECATED]────────────────────────────────┐
│ This script is deprecated. Use pip instead: │
│                                             │
│   pip install apache-polaris                │
└─────────────────────────────────────────────┘
Polaris profile dev_http: {'client_id': 'abc', 'client_secret': '********', 'host': 'localhost', 'port': 8181, 'scheme': 'http', 'realm': '', 'header': 'Polaris-Realm'}

Validation to ensure scheme got honored during api requests:

# https scheme
➜  polaris git:(main) ✗ ./polaris --profile dev_https catalogs list --debug
┌─[DEPRECATED]────────────────────────────────┐
│ This script is deprecated. Use pip instead: │
│                                             │
│   pip install apache-polaris                │
└─────────────────────────────────────────────┘
Request: POST https://localhost:8181/api/catalog/v1/oauth/tokens
Headers: {'Content-Type': 'application/x-www-form-urlencoded'}
Body: <redacted sensitive authentication payload>
...

# http scheme
➜  polaris git:(main) ✗ ./polaris --profile dev_http catalogs list --debug
┌─[DEPRECATED]────────────────────────────────┐
│ This script is deprecated. Use pip instead: │
│                                             │
│   pip install apache-polaris                │
└─────────────────────────────────────────────┘
Request: POST http://localhost:8181/api/catalog/v1/oauth/tokens
Headers: {'Content-Type': 'application/x-www-form-urlencoded'}
Body: <redacted sensitive authentication payload>
...

Ensure change is backward compatible:

# older profile without those extra files in the schema (fall-back to default)
➜  polaris git:(cli_add_scheme_support) ./polaris profiles get dev
┌─[DEPRECATED]────────────────────────────────┐
│ This script is deprecated. Use pip instead: │
│                                             │
│   pip install apache-polaris                │
└─────────────────────────────────────────────┘
Polaris profile dev: {'client_id': 'root', 'client_secret': '********', 'host': 'localhost', 'port': 8181}

# Sample request to ensure it still works
➜  polaris git:(cli_add_scheme_support) ./polaris --profile dev catalogs list --debug
┌─[DEPRECATED]────────────────────────────────┐
│ This script is deprecated. Use pip instead: │
│                                             │
│   pip install apache-polaris                │
└─────────────────────────────────────────────┘
Request: POST http://localhost:8181/api/catalog/v1/oauth/tokens
Headers: {'Content-Type': 'application/x-www-form-urlencoded'}
Body: <redacted sensitive authentication payload>
Response: 200
Response Headers: {'Content-Type': 'application/json;charset=UTF-8', 'content-length': '757', 'X-Request-ID': 'c74784fa-9391-4178-b959-4bbee98d68eb_0000000000000000007'}
Response Body: <redacted sensitive authentication payload>

Request: GET http://localhost:8181/api/management/v1/catalogs
Headers: {'Accept': 'application/json', 'User-Agent': 'OpenAPI-Generator/1.0.0/python', 'Authorization': '***REDACTED***'}
Response: 200
Response Headers: {'Content-Type': 'application/json;charset=UTF-8', 'content-length': '15', 'X-Request-ID': 'c74784fa-9391-4178-b959-4bbee98d68eb_0000000000000000008'}
Response Body: {"catalogs": []}

Checklist

  • 🛡️ Don't disclose security issues! (contact security@apache.org)
  • 🔗 Clearly explained why the changes are needed, or linked related issues: Fixes #
  • 🧪 Added/updated tests with good coverage, or manually tested (and explained how)
  • 💡 Added comments for complex logic
  • 🧾 Updated CHANGELOG.md (if needed)
  • 📚 Updated documentation in site/content/in-dev/unreleased (if needed)

dimas-b
dimas-b previously approved these changes Jul 13, 2026
@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board Jul 13, 2026
flyrain
flyrain previously approved these changes Jul 13, 2026

@flyrain flyrain 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. Thanks @MonkeyCanCode for the fix. I think we will need to update the doc to reflect the new option. I'm OK with a followup.

current_client_secret = profiles[name].get("client_secret")
current_host = profiles[name].get("host")
current_port = profiles[name].get("port")
current_scheme = profiles[name].get(Arguments.SCHEME) or DEFAULT_SCHEME

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.

Good backward-compat handling here! .get(SCHEME) or DEFAULT_SCHEME means profiles created before this change update cleanly to http. Same pattern in base_url.

@MonkeyCanCode

Copy link
Copy Markdown
Contributor Author

LGTM. Thanks @MonkeyCanCode for the fix. I think we will need to update the doc to reflect the new option. I'm OK with a followup.

Good point. Yes, let me update the PR for fixing changlog then I will sync and update this one.

@MonkeyCanCode
MonkeyCanCode dismissed stale reviews from flyrain and dimas-b via 1bdfa75 July 14, 2026 06:18
@MonkeyCanCode
MonkeyCanCode requested review from dimas-b and flyrain July 14, 2026 06:18
@MonkeyCanCode

Copy link
Copy Markdown
Contributor Author

LGTM. Thanks @MonkeyCanCode for the fix. I think we will need to update the doc to reflect the new option. I'm OK with a followup.

Good point. Yes, let me update the PR for fixing changlog then I will sync and update this one.

This is now completed along with updated CHANGEME.md.

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

One gap worth closing: --scheme on the CLI flag is validated against choices=["http","https"], but profiles create/update take it through a raw input() prompt with no validation, so a typo there gets baked straight into base_url unchecked.

2 cents: run the prompt value through the same allowlist.

Comment thread client/python/apache_polaris/cli/command/profiles.py Outdated
Comment thread client/python/apache_polaris/cli/command/profiles.py Outdated
@MonkeyCanCode

Copy link
Copy Markdown
Contributor Author

One gap worth closing: --scheme on the CLI flag is validated against choices=["http","https"], but profiles create/update take it through a raw input() prompt with no validation, so a typo there gets baked straight into base_url unchecked.

2 cents: run the prompt value through the same allowlist.

Thanks for the feedback. This had been handled now.

@MonkeyCanCode
MonkeyCanCode requested a review from flyingImer July 15, 2026 00:05
dimas-b
dimas-b previously approved these changes Jul 16, 2026
Comment thread client/python/apache_polaris/cli/command/profiles.py Outdated
@MonkeyCanCode
MonkeyCanCode merged commit 1d0e0ff into apache:main Jul 17, 2026
25 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to merge to Done in Basic Kanban Board Jul 17, 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.

CLI profile host/port mode hardcodes http scheme, causing http://host:443 for HTTPS deployments

4 participants