Skip to content

fix: improve OSS Index Error Reporting#7977

Merged
jeremylong merged 4 commits intomainfrom
ossIndex401
Sep 27, 2025
Merged

fix: improve OSS Index Error Reporting#7977
jeremylong merged 4 commits intomainfrom
ossIndex401

Conversation

@jeremylong
Copy link
Collaborator

Description of Change

ODC was not properly reporting authorization error messages. Previously, it was looking for the message to end with 401 to report an authorization issue. However, the actual error message from the client is Failed to request component-reports: https://ossindex.sonatype.org/api/v3/component-report - Server status: 401 - Server reason: Unauthorized. As such, the check for 401 needed to be improved.

Related issues

Best guess this is related to #7975 and possibly #7971

Have test cases been added to cover the new functionality?

Yes

@stefano-1973
Copy link

stefano-1973 commented Sep 25, 2025

For the issues #7976 shouldn't be managed in the code also the status code 407 ? (Proxy Authorization Required error)

@jeremylong
Copy link
Collaborator Author

The original code had a few paths that would end up throwing the exception without checking the warn only flag. The updated version doesn't - even though we aren't specifically checking for a 407 it won't hit a path that throws the exception if you configure warn only.

Copy link
Collaborator

@marcelstoer marcelstoer left a comment

Choose a reason for hiding this comment

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

LGTM

@defaultbranch
Copy link

defaultbranch commented Sep 26, 2025

Thanks @jeremylong for keeping the tool working!

requestDelay();
reports = requestReports(engine.getDependencies());
} catch (TransportException ex) {
} catch (SocketTimeoutException e) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that the previous code also only specifically looked at SocketTimeoutException but it occurs to me that there are probably a number of other IOExceptions which essentially relate to an issue with the remote. I guess they will be handled by the generic catch (Exception ex) block, and depends how many the client wraps with TransportException which is a bit messy to unpack. Still this is not 'worse ' :-)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The code was checking for a 401 inside the TransportExceptions - but it was not a transport exception so the code never worked. I agree, this isn't "worse" but we could do better.

Co-authored-by: Chad Wilson <29788154+chadlwilson@users.noreply.github.com>
@jeremylong jeremylong merged commit eaa76f9 into main Sep 27, 2025
7 checks passed
@jeremylong jeremylong deleted the ossIndex401 branch September 27, 2025 19:59
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

core changes to core tests test cases

Projects

None yet

5 participants