Skip to content

[ENH] Add OpenMLAuthenticationError for clearer API key error handling#1570

Open
Omswastik-11 wants to merge 10 commits intoopenml:mainfrom
Omswastik-11:issue-1562
Open

[ENH] Add OpenMLAuthenticationError for clearer API key error handling#1570
Omswastik-11 wants to merge 10 commits intoopenml:mainfrom
Omswastik-11:issue-1562

Conversation

@Omswastik-11
Copy link
Contributor

@Omswastik-11 Omswastik-11 commented Dec 29, 2025

Overview

This PR introduces a new OpenMLAuthenticationError exception to clearly distinguish authentication errors (invalid or missing API key) from authorization errors (valid API key without sufficient permissions).


Changes

New Exception

  • Added OpenMLAuthenticationError in exceptions.py

  • Inherits from OpenMLServerError for consistency

  • Automatically appends helpful guidance with links to:

  • Includes a clear docstring explaining the difference between authentication and authorization errors


Updated Error Handling

  • Updated _api_calls.py to:

    • Import and raise OpenMLAuthenticationError for authentication failures

Tests Updated

  • Updated test_authentication_endpoints_requiring_api_key_show_relevant_help_link

    • Now expects OpenMLAuthenticationError instead of OpenMLNotAuthorizedError
    • Continues to assert that helpful guidance is included in the error message

Fixes #1562

@Omswastik-11 Omswastik-11 changed the title [ENH] add openmlauthentication Error exception [ENH] Add OpenMLAuthenticationError for clearer API key error handling Dec 29, 2025
@codecov-commenter
Copy link

codecov-commenter commented Jan 6, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.08%. Comparing base (d18ca42) to head (4c59099).

Files with missing lines Patch % Lines
openml/_api_calls.py 0.00% 2 Missing ⚠️
openml/exceptions.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1570      +/-   ##
==========================================
- Coverage   52.08%   52.08%   -0.01%     
==========================================
  Files          36       36              
  Lines        4360     4364       +4     
==========================================
+ Hits         2271     2273       +2     
- Misses       2089     2091       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@jgyasu jgyasu left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Copy link
Collaborator

@geetu040 geetu040 left a comment

Choose a reason for hiding this comment

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

Really Nice.
It was important to identify correct usage of OpenMLNotAuthorizedError and OpenMLAuthenticationError in the sdk, which looks all good.
Ready to be merged.

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Waitasec, could you kindly explain why the OpenMLNotAuthorizedError gets removed?

@Omswastik-11
Copy link
Contributor Author

@fkiraly it is not completely removed but replaced . I have done it according to this :
#1562 (comment)

@fkiraly
Copy link
Collaborator

fkiraly commented Feb 16, 2026

if i understand @SimonBlanke correctly, he does not want it replaced, but a new class added?

@geetu040
Copy link
Collaborator

if i understand @SimonBlanke correctly, he does not want it replaced, but a new class added?

@fkiraly the new class is added and the previous one is still there: openml/exceptions.py

the confusion is probably coming from openml/_api_calls.py where OpenMLNotAuthorizedError return is replaced with OpenMLAuthenticationError

Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Ah, you are right, I was confused - this is a removed import, not a removed export.

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.

[ENH] Add OpenMLAuthenticationError and improve Error Message When API Key is Invalid

5 participants