Skip to content

Comments

fix: auto-retry on 401 Unauthorized after idle timeout#35

Open
kts982 wants to merge 1 commit intooisee:mainfrom
kts982:fix/401-auto-retry
Open

fix: auto-retry on 401 Unauthorized after idle timeout#35
kts982 wants to merge 1 commit intooisee:mainfrom
kts982:fix/401-auto-retry

Conversation

@kts982
Copy link
Contributor

@kts982 kts982 commented Feb 23, 2026

Summary

  • After idle periods, the first request returns 401 Unauthorized and surfaces the error to the caller
  • Now the transport clears cached tokens, re-authenticates, and retries once
  • Matches the existing retry patterns for 403 (CSRF) and 400 (session timeout)

Test plan

  • go test ./pkg/adt/ -run TestTransport — all 13 transport tests pass
  • New tests: TestTransport_Request_RetryOn401 (GET) and TestTransport_Request_RetryOn401_POST (POST)
  • go build ./pkg/adt/ — compiles cleanly

Refs #32

When SAP sessions expire after idle periods, the first request returns
401 Unauthorized. Previously this error surfaced directly to the caller,
wasting a round-trip. Now the transport clears cached tokens,
re-authenticates, and retries once — matching the existing patterns
for 403 (CSRF refresh) and 400 (session timeout).

Adds unit tests for both GET and POST 401 retry scenarios.

Refs oisee#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.

1 participant