Fix escaping of quotes inside string variables#9179
Conversation
10c4b2a to
891393b
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in JSON string value parsing where escaped quotes inside string variables were not being properly unescaped. The old implementation manually stripped the surrounding quotes from the raw JSON UTF-8 bytes but didn't handle escape sequences. The fix replaces this with element.GetString() which properly handles all JSON escape sequences including \".
Changes:
- Simplified string parsing logic in
JsonValueParserandJsonVariableCoercionto useelement.GetString()instead of manual quote stripping - Added comprehensive tests across multiple test projects to verify escaped quotes are properly handled
- Removed unnecessary braces from String case blocks in switch statements
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
src/HotChocolate/Language/src/Language.Web/JsonValueParser.cs |
Replaced manual quote-stripping logic with element.GetString() for proper escape handling; removed braces from String and Number cases |
src/HotChocolate/Fusion-vnext/src/Fusion.Execution/Execution/JsonVariableCoercion.cs |
Applied same fix to JSON variable coercion logic; removed braces from String and Number cases |
src/HotChocolate/Language/test/Language.Web.Tests/JsonValueParserTests.cs |
Added new test file verifying escaped quotes are properly unescaped in JSON parsing |
src/HotChocolate/Fusion-vnext/test/Fusion.Execution.Tests/Execution/VariableCoercionHelperTests.cs |
Added test for variable coercion with escaped quotes at the Fusion execution level |
src/HotChocolate/Core/test/Execution.Tests/Processing/VariableCoercionHelperTests.cs |
Added test for variable coercion with escaped quotes at the core execution level |
src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/VariableCoercionTests.cs |
Added integration test and test schema definition for end-to-end verification |
src/HotChocolate/Fusion-vnext/test/Fusion.AspNetCore.Tests/__snapshots__/VariableCoercionTests.String_With_Quotes.yaml |
Snapshot file capturing expected behavior for the integration test |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Fusion Gateway Performance ResultsSimple Composite Query
Response Times & Query
query TestQuery {
topProducts(first: 5) {
inStock
name
price
shippingEstimate
upc
weight
reviews {
id
body
author {
id
username
name
}
}
}
}Deep Recursion Query
Response Times & Query
query TestQuery {
users {
id
username
name
reviews {
id
body
product {
inStock
name
price
shippingEstimate
upc
weight
reviews {
id
body
author {
id
username
name
reviews {
id
body
product {
inStock
name
price
shippingEstimate
upc
weight
}
}
}
}
}
}
}
topProducts(first: 5) {
inStock
name
price
shippingEstimate
upc
weight
reviews {
id
body
author {
id
username
name
reviews {
id
body
product {
inStock
name
price
shippingEstimate
upc
weight
}
}
}
}
}
}Variable Batching Throughput
Response Times & Query
query TestQuery($upc: ID!, $price: Long!, $weight: Long!) {
productByUpc(upc: $upc) {
inStock
shippingEstimate(weight: $weight, price: $price)
}
}Variables (5 sets batched per request) [
{ "upc": "1", "price": 899, "weight": 100 },
{ "upc": "2", "price": 1299, "weight": 1000 },
{ "upc": "3", "price": 15, "weight": 20 },
{ "upc": "4", "price": 499, "weight": 100 },
{ "upc": "5", "price": 1299, "weight": 1000 }
]Run 22313375953 • Commit 3bc9a16 • Mon, 23 Feb 2026 16:58:56 GMT |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #9179 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.