Skip to content

HCK-15381: fix possible JSON parse error#326

Merged
VitaliiBedletskyi merged 1 commit intodevelopfrom
fix/HCK-15381
Mar 19, 2026
Merged

HCK-15381: fix possible JSON parse error#326
VitaliiBedletskyi merged 1 commit intodevelopfrom
fix/HCK-15381

Conversation

@taras-dubyk
Copy link
Contributor

Content

Fix JSON parse error in filterCorruptedData when Databricks response is truncated mid-table

When reverse engineering large schemas, Databricks may truncate API responses by inserting a *** WARNING: max output size exceeded, skipping output. *** marker in the middle of the output. The filterCorruptedData function attempts to recover valid JSON by discarding incomplete objects from both sides of the split.

Root cause: Two bugs in the isTruncatedInMiddle branch:

  • Wrong join delimiter — filtered chunks were joined with ', ' instead of JSON_OBJECTS_DELIMITER (}, {). This consumed the object boundary, merging two table objects into one and causing silent data loss (duplicate keys resolved by last-wins semantics).

  • Empty chunk not handled — when the second chunk contains only a single incomplete table (no }, { delimiter), filterCorruptedStart returns an empty string. Joining with ', ' produced a trailing comma ("..., ") which caused JSON.parse to throw: SyntaxError: Expected double-quoted property name in JSON at position ...

Fix:

  • Use JSON_OBJECTS_DELIMITER for joining to preserve proper JSON object boundaries
  • Filter out empty strings before joining
  • Conditionally append }]} only when the last chunk contributed no complete tables

@taras-dubyk taras-dubyk self-assigned this Mar 18, 2026
@sonarqubecloud
Copy link

@VitaliiBedletskyi VitaliiBedletskyi merged commit 9023b18 into develop Mar 19, 2026
2 checks passed
@VitaliiBedletskyi VitaliiBedletskyi deleted the fix/HCK-15381 branch March 19, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants