Skip to content

[Phase 4] MSSQL JSON - malformed-JSON (400) + filter edge-case tests - #3751

Open
souvikghosh04 wants to merge 3 commits into
mainfrom
Usr/sogh/mssql-json-phase4
Open

[Phase 4] MSSQL JSON - malformed-JSON (400) + filter edge-case tests#3751
souvikghosh04 wants to merge 3 commits into
mainfrom
Usr/sogh/mssql-json-phase4

Conversation

@souvikghosh04

@souvikghosh04 souvikghosh04 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Resolves #3752

Why

Phase 4 of MSSQL native JSON support (#2768) — error-handling and filter edge cases. Builds on the merged engine + schema-discovery work (#3691, #3720, #3738).

What

User story Test Asserts
US7 — REST InsertMalformedJson_ReturnsBadRequest Posting invalid JSON for the json column is rejected by SQL Server and surfaced as HTTP 400 (not 500), exercising the 13608–13614 → BadRequest mapping
US7 — GraphQL JsonColumn_GraphQLCreateWithMalformedJson_Fails A createProfile mutation with malformed JSON fails with a GraphQL error (mirrors the merged vector-type pattern in MsSqlGraphQLVectorTypesTests)
US9 — REST FilterJsonColumnIsNotNull_Succeeds Filtering a json column as a string ($filter=metadata ne null) passes through to SQL and returns the 4 non-null rows

Because DAB treats json as a normal string and does no pre-validation, invalid JSON is caught at the database boundary and mapped to a client error — consistent with the "nothing special" contract.

Deferred (pending CI observation)

  • Pruning 13608–13614: kept the full documented JSON-validation range for now. Removing a code that actually fires would regress it to a 500, so I'd rather confirm the exact code(s) SQL 2025 emits (via this PR's CI run) before narrowing the list.
  • Sort / equality on a json column: SQL Server disallows comparing/sorting the native json type (except IS [NOT] NULL), so $orderby=metadata / metadata eq '…' behavior + error-code mapping needs CI confirmation before I assert on it.

Notes

  • Tests only — no product code changes.
  • Requires SQL Server 2025 / Azure SQL (native json); CI already runs SQL 2025.
  • Cannot be run locally (no SQL 2025 here) — relying on CI.

Delivery plan

Phase What Status
1 .NET 10 + SqlClient 6.x ✅ Merged (#3697/#3656)
2 JSON type + error mapping (engine) ✅ Merged (#3691)
3 Test fixture + REST CRUD tests ✅ Merged (#3720)
3b json-as-string read fix + OpenAPI/GraphQL tests ✅ Merged (#3738)
4 Error / filter edge cases (this PR) 🚧

…sts (Phase 4)

Covers the JSON error-handling and filter user stories from #2768:

- US7 REST: InsertMalformedJson_ReturnsBadRequest - posting invalid JSON for the json column is rejected by SQL Server and surfaced as HTTP 400 (not 500), exercising the 13608-13614 -> BadRequest mapping.

- US7 GraphQL: JsonColumn_GraphQLCreateWithMalformedJson_Fails - a createProfile mutation with malformed JSON fails with a GraphQL error (mirrors the merged vector-type pattern).

- US9 REST: FilterJsonColumnIsNotNull_Succeeds - filtering a json column as a string (metadata ne null) passes through to SQL and returns the 4 non-null rows.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Phase 4 integration coverage for SQL Server 2025 native json columns, validating malformed-JSON error handling and a REST filter edge case to ensure DAB continues treating json as a normal string while surfacing database validation errors as client-facing failures.

Changes:

  • Added REST test coverage for $filter=metadata ne null (IS NOT NULL behavior) on json columns.
  • Added REST test coverage ensuring malformed JSON inserts are surfaced as HTTP 400 (not 500).
  • Added GraphQL mutation test coverage ensuring malformed JSON creates fail with a GraphQL error.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/Service.Tests/SqlTests/RestApiTests/MsSqlRestJsonTypesTests.cs Adds REST tests for json column filter IS NOT NULL behavior and HTTP 400 mapping on malformed JSON inserts.
src/Service.Tests/SqlTests/GraphQLQueryTests/MsSqlGraphQLJsonSchemaTests.cs Adds GraphQL mutation test for malformed JSON create failure behavior.

Comment thread src/Service.Tests/SqlTests/RestApiTests/MsSqlRestJsonTypesTests.cs Outdated
Comment thread src/Service.Tests/SqlTests/GraphQLQueryTests/MsSqlGraphQLJsonSchemaTests.cs Outdated
souvikghosh04 and others added 2 commits August 4, 2026 14:07
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Review In Progress

Development

Successfully merging this pull request may close these issues.

[Phase 4] MSSQL JSON - error handling + filter edge cases

4 participants