Fix: Gateway Tags Serialization Bug & Transport Reset Issue#2650
Merged
crivetimihai merged 1 commit intomainfrom Feb 6, 2026
Merged
Fix: Gateway Tags Serialization Bug & Transport Reset Issue#2650crivetimihai merged 1 commit intomainfrom
crivetimihai merged 1 commit intomainfrom
Conversation
Member
|
Clean fix for both the tags serialization and transport reset issues. The dict passthrough in LGTM — ready to merge. |
adb5d59 to
55e56f2
Compare
Collaborator
Author
|
@crivetimihai, I have resolved the merge conflicts and rebased the PR. |
55e56f2 to
6124751
Compare
Closes #2563 This commit fixes two issues: 1. Gateway Tags Returned as Empty List (#2563): - Fixed type annotation mismatch in validate_tags_field() to correctly return List[Dict[str, str]] instead of List[str] - Added passthrough logic for already-formatted tag dictionaries in TagValidator.validate_list() - Updated GatewayCreate.tags and GatewayUpdate.tags to accept both legacy string format and new dict format - Fixed parenthesis placement in get_gateway_by_url() to correctly call masked() on GatewayRead instead of DbGateway 2. Transport Field Reset During Gateway Update: - Changed GatewayUpdate.transport from default="SSE" to None to prevent overwriting existing values when field is omitted in PUT/PATCH requests Co-authored-by: rakdutta <rakhibiswas@yahoo.com> Signed-off-by: Mihai Criveti <crivetimihai@gmail.com>
6124751 to
c0bea99
Compare
kcostell06
pushed a commit
to kcostell06/mcp-context-forge
that referenced
this pull request
Feb 24, 2026
Closes IBM#2563 This commit fixes two issues: 1. Gateway Tags Returned as Empty List (IBM#2563): - Fixed type annotation mismatch in validate_tags_field() to correctly return List[Dict[str, str]] instead of List[str] - Added passthrough logic for already-formatted tag dictionaries in TagValidator.validate_list() - Updated GatewayCreate.tags and GatewayUpdate.tags to accept both legacy string format and new dict format - Fixed parenthesis placement in get_gateway_by_url() to correctly call masked() on GatewayRead instead of DbGateway 2. Transport Field Reset During Gateway Update: - Changed GatewayUpdate.transport from default="SSE" to None to prevent overwriting existing values when field is omitted in PUT/PATCH requests Signed-off-by: Mihai Criveti <crivetimihai@gmail.com> Co-authored-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.
Closes #2563
This PR primarily fixes Issue #2563, where Gateway tags were returned as an empty list despite being present in the database.
During unit testing for this fix, an additional but related issue was discovered in the Gateway update flow, which is also addressed here.
Primary Issue (#2563): Gateway Tags Returned as Empty List
Problem
Gateway APIs (
GET / PUT / PATCH) returnedtags: []even when valid tag data existed in the PostgreSQL JSON column.Root Causes
Type annotation mismatch
validate_tags_field()was annotated as returningList[str]but actually returnedList[Dict[str, str]], causing Pydantic serialization/coercion issues.Dict input destruction during validation
TagValidator.validate_list()stringified dict inputs (e.g.{"id": "finance", "label": "Finance"}), which then failed validation and were filtered out.Missing legacy tag normalization
_prepare_gateway_for_read()did not convert legacy string tags to dict format before validation.Fixes Implemented
mcpgateway/validation/tags.pyCorrected
validate_tags_field()return type toList[Dict[str, str]]Added passthrough logic for already-formatted tag dictionaries:
mcpgateway/schemas.pyUpdated
GatewayCreate.tagsandGatewayUpdate.tagsto accept both legacy and new formats:Aligned validator return type annotations with actual return values
mcpgateway/services/gateway_service.py_prepare_gateway_for_read()to normalize legacy string tags into dict format prior to validationResult
Gateway tags now serialize and deserialize correctly across all API endpoints, preserving both
idandlabelfields from the database.Additional Issue Found During Unit Testing: Transport Field Reset
Problem
While validating the tags fix via unit tests, it was observed that updating a gateway without explicitly providing
transportcaused the field to reset to"SSE"instead of preserving the existing value (e.g."STREAMABLEHTTP").Root Cause
In
GatewayUpdateschema:This caused omitted fields in
PUT / PATCHrequests to overwrite existing values, which violates REST API semantics.Fix Implemented
Updated
GatewayUpdate.transportto default toNone:Ensures existing values are preserved unless explicitly provided in the request
Testing
Verified via curl:
After the fix:
transportremains unchanged unless explicitly passed