fix: add auth_code guard to set_gateway_state stale cleanup#3792
Merged
crivetimihai merged 7 commits intoIBM:mainfrom Mar 23, 2026
Merged
fix: add auth_code guard to set_gateway_state stale cleanup#3792crivetimihai merged 7 commits intoIBM:mainfrom
crivetimihai merged 7 commits intoIBM:mainfrom
Conversation
When an OAuth authorization_code gateway transitions from offline to online, set_gateway_state re-initializes without a valid token, receives empty results, and deletes all existing tools/resources/prompts as stale. Add the same auth_code guard that _refresh_gateway_tools_resources_prompts already has (PR IBM#2537): skip stale cleanup when the response is empty for authorization_code gateways. Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
Replace string-parsing assert with call_count check to match the existing test patterns in test_gateway_service.py. Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
Skip gateway.tools/resources/prompts list filtering when stale cleanup is skipped, and verify all existing tools are preserved by id. Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
Rename _is_auth_code_gw to is_auth_code_gateway and _skip_stale_cleanup to skip_stale_cleanup to match _refresh_gateway_tools_resources_prompts naming. Signed-off-by: kimsehwan96 <sktpghks138@gmail.com>
Add two tests for set_gateway_state auth_code guard: - Non-auth_code gateway with empty results still runs stale cleanup - Auth_code guard preserves resources and prompts (not just tools) Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
Verify that an authorization_code gateway returning partial results (some tools) still runs stale cleanup, ensuring the guard only activates when all three collections are empty. Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
de86e0a to
5da5e3d
Compare
Member
|
Rebased onto main (clean, no conflicts) and added three additional tests for full differential coverage:
All 272 tests pass (271 passed, 1 pre-existing skip). The guard logic is correct and consistent with the existing pattern in |
crivetimihai
previously approved these changes
Mar 23, 2026
Member
crivetimihai
left a comment
There was a problem hiding this comment.
LGTM — guard is correct, consistent with the existing pattern, and well-tested.
Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
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.
🔗 Related Issue
Closes #3788
📝 Summary
When an auth_code gateway transitions from offline → online,
set_gateway_statecalls_initialize_gatewaywhich connects without a valid OAuth token, receives empty results, and deletes all existing tools, resources, prompts, and their virtual server associations as "stale."This PR mirrors the existing guard from
_refresh_gateway_tools_resources_prompts(line 4558) intoset_gateway_state, skipping stale cleanup when the response is empty for authorization_code gateways.🏷️ Type of Change
🧪 Verification
make lintmake testmake coverage✅ Checklist
make black isort pre-commit)📓 Notes (optional)
What the guard protects:
server_tool_association)gateway.tools = [...]filtering)What it does NOT change: