Skip to content

Conversation

@harishva23
Copy link

@harishva23 harishva23 commented Oct 24, 2025

About this change - What it does

This PR fixes 2 issues - error handling inside the follower and error handling for file-based basic authentication

Earlier, the follower could not parse error messages from leader if write requests were made to the follower and it failed due to some error like incompatible or invalid schema , trying to delete a non-existent schema etc. Now this is able to handle these error messages and pass it on to the user or client.

In the file-based authentication, if a non-existent user was sent in the Headers ( a username not in auth file), karapace threw an Internal Server Error instead of Unauthorized message. This did not happen when a correct username but wrong password was passed. So I have fixed this issue and it returns an Unauthorized error message for both the cases.

References: #1154

Why this way

Since Confluent client always expects a FastAPI response, I have changed the code to return proper format of error messages from follower. This leads to consistent error messages from both leader and follower so that the user can decide the next steps.

For the file-based authentication, raising a generic ValueError results in Internal Server Error being thrown and a full stacktrace appears in the logs which reveals that User is not found. Since karapace already throws a Unauthorised Error if wrong password is sent, I have removed the logic raising ValueError and instead returning None type which is then handled in the auth.py file in the authenticate function.

@harishva23 harishva23 requested a review from a team as a code owner October 24, 2025 10:13
@muralibasani
Copy link
Contributor

@harishva23 thanks for the pr. Can you add any unit/integration tests ?

@harishva23
Copy link
Author

@harishva23 thanks for the pr. Can you add any unit/integration tests ?

Hi, Thanks for the reply, it will take some time for me to add some tests. Can I add it in this PR itself?

@muralibasani
Copy link
Contributor

@harishva23 thanks for the pr. Can you add any unit/integration tests ?

Hi, Thanks for the reply, it will take some time for me to add some tests. Can I add it in this PR itself?

Yes pls

@harishva23 harishva23 closed this Nov 5, 2025
@harishva23 harishva23 force-pushed the fix/follower-error-handling-clean branch from 44025bf to 0279ec3 Compare November 5, 2025 04:56
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.

2 participants