Skip to content

Report list endpoint errors from SimpleEntityCollector - #219

Open
topperge wants to merge 1 commit into
go-oidfed:mainfrom
topperge:fix/report-list-refusals
Open

topperge wants to merge 1 commit into
go-oidfed:mainfrom
topperge:fix/report-list-refusals

Conversation

@topperge

Copy link
Copy Markdown
Contributor

Fixes #217.

SimpleEntityCollector now reports the list and collection errors it used to only log, so a caller can tell a federation that does not publish its member list from one that has none:

  • New SimpleEntityCollector.OnListError func(authority string, err error). It is called, in addition to the existing log line, wherever the collector met an error reading an authority's federation_list_endpoint or a subordinate's federation_collection_endpoint. It may be called concurrently. A nil hook changes nothing.
  • New ListRefusedError{Authority, Status}. httpFetchList returns it:
    • for a 401 or 403 answer;
    • without sending a request (Status 0) when federation_list_endpoint_auth_methods lacks none and no client authentication can satisfy it. private_key_jwt with DefaultClientAuth set is not a refusal.
  • A failed collection endpoint is reported only when no list traversal follows it, because a failing list traversal reports itself.

Tests (entity_collection_refusal_test.go):

  • a trust anchor whose list answers 401: hook called, collection empty;
  • an intermediate whose list answers 403: the rest is still collected;
  • a refused collection endpoint followed by a working list: not reported;
  • a refused collection endpoint without a list: reported;
  • a nil hook;
  • an authority advertising authentication.

The new tests fail to build on main, because the hook and error type don't exist there, and pass with this change. go test ./... passes. go vet reports the same five copylocks warnings in mock_tm.go and trustanchor.go as on main.

The changelog entry goes under a new "Features" heading in "Unreleased". #218 builds on this change and is opened as a separate PR.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QYDqsx3UGxpCKvCiUxShZq

SimpleEntityCollector only logged a failed federation_list_endpoint or
federation_collection_endpoint request, so a caller got an empty or
partial collection whether the federation had no members, refused the
request (401/403, or required client authentication), or was down.

The collector now calls an optional OnListError hook wherever it logged
such an error. Refusals are reported as *ListRefusedError{Authority,
Status}: httpFetchList returns it for a 401 or 403 answer, and without
sending a request (Status 0) when federation_list_endpoint_auth_methods
lacks "none" and no client authentication can satisfy it (private_key_jwt
with DefaultClientAuth set is not a refusal). A failed collection
endpoint is reported only when no list traversal follows it, since a
failing list traversal reports itself. A nil hook changes nothing.

Fixes go-oidfed#217

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QYDqsx3UGxpCKvCiUxShZq
@deepsource-io

deepsource-io Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

DeepSource Code Review

We reviewed changes in be2f2ed...f75aa6b on this pull request. Below is the summary for the review, and you can see the individual issues we found as inline review comments.

See full review on DeepSource ↗

PR Report Card

Overall Grade   Security  

Reliability  

Complexity  

Hygiene  

Code Review Summary

Analyzer Status Updated (UTC) Details
Go Nov 12, 2026 3:45p.m. Review ↗
Code coverage Nov 12, 2026 4:15p.m. Review ↗

Important

AI Review is run only on demand for your team. We're only showing results of static analysis review right now. To trigger AI Review, comment @deepsourcebot review on this thread.

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.

SimpleEntityCollector: report list endpoint errors, so "not published" can be told from "empty"

1 participant