fix: enforce per-task push notification config limit - #1044
Open
ez-lbz wants to merge 1 commit into
Open
Conversation
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.
What changed
1. Enforce a per-task push notification config limit
Problem:
InMemoryPushNotificationConfigStore.setInfomaintained an unboundedList<TaskPushNotificationConfig>per task. A client could register unlimited push notification configs for one task; each config consumes memory and can trigger an outbound HTTP request on every task event, enabling resource exhaustion and amplified outbound traffic.Fix (server-common/src/main/java/org/a2aproject/sdk/server/tasks/InMemoryPushNotificationConfigStore.java):
MAX_PUSH_CONFIGS_PER_TASK = 100(matching the Python SDK's cap).setInfonow counts only new configs against the limit: re-registering/updating an already-registered config ID remains allowed. When a genuinely new config would exceed the limit,setInfothrowsInvalidParamsError(code -32602), the same error family already used for push-config validation, which transports surface as a client error.Fix (server-common/src/test/java/org/a2aproject/sdk/server/tasks/InMemoryPushNotificationConfigStoreTest.java):
testSetInfoAtLimitExactlyAllowed— the 100th config still succeeds.testSetInfoRejectsExceedingPerTaskLimit— the 101st distinct config throwsInvalidParamsErrorand the store is unchanged.testSetInfoUpdateExistingConfigAtLimitAllowed— updating an existing config at the limit is still allowed.Behavior change: registering more than 100 distinct push notification configs for a single task now fails with
InvalidParamsErrorinstead of succeeding. Updates to existing configs are unaffected.Testing
mvn -pl server-common test— 450 tests run, 0 failures, 0 errors, 0 skipped (BUILD SUCCESS), including the 3 new regression tests.