fix: Session not found — use stateless ADT sessions by default#79
Open
snymanpaul wants to merge 1 commit intooisee:mainfrom
Open
fix: Session not found — use stateless ADT sessions by default#79snymanpaul wants to merge 1 commit intooisee:mainfrom
snymanpaul wants to merge 1 commit intooisee:mainfrom
Conversation
Root cause: NewConfig defaulted to SessionStateful, which made SAP ICF return sap-contextid cookies. These cookies bound the session to the first ADT endpoint (/core/discovery). When subsequent requests went to different endpoints (/datapreview/freestyle), EDZ looked for the context ID in the wrong session pool → "Session not found" (400). Fixes: 1. server.go: Set WithSessionType(SessionStateless) for MCP server — prevents sap-contextid from being issued while keeping MYSAPSSO2 and sap-XSRF cookies for CSRF correlation 2. http.go: IsSessionExpired() now matches "session not found" (EDZ's actual error text, previously only matched "session timed out") 3. http.go: Session recovery clears cookie jar to discard stale cookies 4. http.go: setDefaultHeaders defaults to stateless session type 5. config.go: Cookie jar always created (needed for CSRF correlation) regardless of session type Symptoms: Every second MCP tool call failed with 400 "Session not found". GET-only operations (SearchObject, GetSource) worked because they don't need CSRF. POST operations (RunQuery, GetTableContents) always failed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SessionTypewasSessionStateful, causing SAP ICF to returnsap-contextidcookies bound to the first ADT endpoint (/core/discovery)/datapreview/freestyle) failed with 400 "Session not found" because EDZ looked for the context ID in the wrong handler poolChanges
server.go: SetWithSessionType(SessionStateless)— preventssap-contextidwhile keepingMYSAPSSO2+sap-XSRFfor CSRFhttp.go:IsSessionExpired()now matches"session not found"(EDZ's actual error text)http.go: Session recovery clears cookie jar via replacement to discard stale cookieshttp.go:setDefaultHeadersdefaults toX-sap-adt-sessiontype: statelessconfig.go: Cookie jar always created regardless of session type (needed for CSRF correlation)Test plan