Skip to content

[Issue #8997] SOAP/Proxy: handle HTTPError Privilege issue without logging exception#9012

Merged
jakobpederson merged 2 commits intomainfrom
jakobpederson/8997-soap-log-httperror-not-exception
Mar 13, 2026
Merged

[Issue #8997] SOAP/Proxy: handle HTTPError Privilege issue without logging exception#9012
jakobpederson merged 2 commits intomainfrom
jakobpederson/8997-soap-log-httperror-not-exception

Conversation

@jakobpederson
Copy link
Collaborator

Summary

Fixes / Work for #8997

Changes proposed

Handled the HTTPError that results when user does not have Privilege to access an application.

Context for reviewers

Previously this was being logged as an exception which was setting off alarms in New Relic. This handles it more gracefully and lessens alarm noise.

Validation steps

@jakobpederson jakobpederson self-assigned this Mar 12, 2026
@jakobpederson jakobpederson changed the title wip [Issue #8997] SOAP/Proxy: handle HTTPError Privilige issue without logging exception Mar 12, 2026
@jakobpederson jakobpederson force-pushed the jakobpederson/8997-soap-log-httperror-not-exception branch 2 times, most recently from 5bab42f to 00bb2d5 Compare March 12, 2026 16:56
@jakobpederson jakobpederson changed the title [Issue #8997] SOAP/Proxy: handle HTTPError Privilige issue without logging exception [Issue #8997] SOAP/Proxy: handle HTTPError Privilege issue without logging exception Mar 12, 2026
@jakobpederson jakobpederson force-pushed the jakobpederson/8997-soap-log-httperror-not-exception branch from 00bb2d5 to 72f239c Compare March 12, 2026 18:30
@jakobpederson jakobpederson marked this pull request as ready for review March 12, 2026 18:55
Comment on lines +102 to +110
except HTTPError:
msg = "soap_client_certificate: User did not have permission to access this application"
logger.info(
msg=msg,
extra={
"soap_api_event": LegacySoapApiEvent.ERROR_CALLING_SIMPLER,
},
)
return soap_proxy_response.to_flask_response()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this overly broad? Is it possible to hit this HTTPError from something other than a permissions issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think the thinking is we only ever explicitly raise an HTTPError in one place in the SOAP/Proxy. I think in the space between this check and the actual response we won't see any other HTTPError. That being said I think you're right and we could easily raise a custom exception so I'll add that.

for record in caplog.records
if record.message == "User did not have permission to access this application"
)
assert post_message.message == "User did not have permission to access this application"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this testing the correct log message (i.e. the one you just added, "soap_client_certificate: User did not have permission to access this application")? I think this is testing the inner log message from get_application_zip_response.py.


Also, is there actually an assertion here that verifies the AC of "not having the correct permission does not log the exception?" I would think we need something verifies that logging did not occur, something like:
error_records = [r for r in caplog.records if r.levelno >= logging.ERROR and "Unable to process Simpler SOAP proxy response" in r.message] assert len(error_records) == 0

Comment on lines +297 to +301
post_message = next(
record
for record in caplog.records
if record.message == "User did not have permission to access this application"
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the assert after this is redundant - if the message isn't found within next() it will raise an error and fail the test, though that would be with an unhelpful failure message. You could do a list comprehension with assert len(...) == 1.

@jakobpederson jakobpederson requested a review from kkrug March 13, 2026 16:00
@jakobpederson jakobpederson merged commit 7cef2bc into main Mar 13, 2026
1 check passed
@jakobpederson jakobpederson deleted the jakobpederson/8997-soap-log-httperror-not-exception branch March 13, 2026 16:32
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