Skip to content

Improve Sirsi patron auth self-test failure feedback (PP-3899)#3155

Merged
jonathangreen merged 4 commits intomainfrom
feature/sirsi-selftest-error-feedback
Mar 19, 2026
Merged

Improve Sirsi patron auth self-test failure feedback (PP-3899)#3155
jonathangreen merged 4 commits intomainfrom
feature/sirsi-selftest-error-feedback

Conversation

@jonathangreen
Copy link
Member

@jonathangreen jonathangreen commented Mar 19, 2026

Description

When SirsiDynix patron auth self-tests fail (login, read patron data, patron status info), the error messages were generic (e.g., "Could not authenticate test patron") with no indication of why the request failed. This PR surfaces the HTTP status code, request method, URL, and response body in the self-test debug_message, which is displayed in the admin UI.

Motivation and Context

Helps troubleshoot PP-3899. Library admins and the support/integrations team can now diagnose SirsiDynix configuration issues directly from the admin UI self-test results, without needing access to server logs.

How Has This Been Tested?

  • New tests
  • Tests pass in CI
  • mypy passes with no errors

Checklist

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@jonathangreen jonathangreen added the feature New feature label Mar 19, 2026
@jonathangreen jonathangreen requested a review from a team March 19, 2026 14:34
@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 93.26%. Comparing base (65b2ff7) to head (4b44309).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
.../patron_auth/sirsidynix_authentication_provider.py 96.87% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3155   +/-   ##
=======================================
  Coverage   93.26%   93.26%           
=======================================
  Files         493      493           
  Lines       45599    45616   +17     
  Branches     6254     6254           
=======================================
+ Hits        42530    42546   +16     
- Misses       1982     1983    +1     
  Partials     1087     1087           

☔ 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
Contributor

@tdilauro tdilauro left a comment

Choose a reason for hiding this comment

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

Looks great! 🪵🚀

I couple small suggestions below, but no show stoppers.

Comment on lines +58 to +59
def __bool__(self) -> bool:
return False
Copy link
Contributor

Choose a reason for hiding this comment

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

Clever trick here, but it looks like you've updated all of the call sites to use isinstance. So, is this method still needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

No needed at all. Seemed like it could prevent a foot-gun in the future though, so I thought I'd leave it in.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the doc string to make the intent clear though, the old one made it sound like it was being actively used.

Comment on lines +433 to +437
debug_message=(
f"Made a {result.method} request to {result.url} "
f"and received HTTP {result.status_code}.\n\n"
f"Response body:\n{result.message}"
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor - The debug message in read_data below is almost identical. We could make this into a format string and use it in both places, if we want to ensure consistency. Or, better yet, we could add a method on SirsiError, since all the variables are coming from it anyway.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just started looking at #3158 and noticed that you're using it there, too, which makes a stronger argument for making this a method on SirsiError.

"""

status_code: int
message: str
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor - "body" or "response_body" instead of "message"?

Surface the HTTP status code and response body in self-test results
via IntegrationException debug_message, so library admins can diagnose
configuration issues from the admin UI without needing server logs.
Add method and url fields to SirsiError, populated via a new
_make_error helper. Self-test debug messages now show the exact
request that failed (e.g. "Made a POST request to ... and received
HTTP 401") along with the response body.
- Rename `message` field to `response_body` for clarity.
- Extract duplicated debug message formatting into a `debug_message`
  property on `SirsiError`.
@jonathangreen jonathangreen force-pushed the feature/sirsi-selftest-error-feedback branch from 7bc0032 to 4b44309 Compare March 19, 2026 20:04
@jonathangreen jonathangreen enabled auto-merge (squash) March 19, 2026 20:04
@jonathangreen jonathangreen merged commit d1005ca into main Mar 19, 2026
20 checks passed
@jonathangreen jonathangreen deleted the feature/sirsi-selftest-error-feedback branch March 19, 2026 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants