Skip to content

fix: cast boolean threshold values to int before sending to Soda Cloud#2659

Merged
Lepo00 merged 2 commits intomainfrom
fix/bool-diagnostics-value-serialization
Apr 14, 2026
Merged

fix: cast boolean threshold values to int before sending to Soda Cloud#2659
Lepo00 merged 2 commits intomainfrom
fix/bool-diagnostics-value-serialization

Conversation

@Lepo00
Copy link
Copy Markdown
Contributor

@Lepo00 Lepo00 commented Apr 13, 2026

Summary

  • When a metric check uses a SQL query returning a boolean (e.g. a comparison expression on Databricks), the raw Python bool flows through to diagnostics.value and gets serialized as JSON true/false instead of 1/0
  • The backend expects a numeric value and rejects the payload with 400 "Could not parse request from json body"
  • Cast bool to int in _build_diagnostics_json_dict so the serialized value is always numeric

Fixes SAS-11624

Test plan

  • Added parametrized unit test covering True, False, numeric, zero, and None threshold values
  • All 6 parametrized cases pass
  • Verify on a Databricks data source with a boolean-returning metric query

Lepo00 and others added 2 commits April 13, 2026 18:19
When a metric check uses a SQL query that returns a boolean (e.g. a
comparison expression on Databricks), the raw Python bool flows through
to `diagnostics.value` and gets serialized as JSON `true`/`false`
instead of `1`/`0`. The backend expects a numeric value and rejects
the payload with 400 "Could not parse request from json body".

Cast bool to int in `_build_diagnostics_json_dict` so the serialized
value is always numeric.

Fixes SAS-11624
@sonarqubecloud
Copy link
Copy Markdown

@Lepo00 Lepo00 requested a review from a team April 13, 2026 16:22
@Lepo00 Lepo00 self-assigned this Apr 13, 2026
Copy link
Copy Markdown
Contributor

@Niels-b Niels-b left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for taking care of this one 🙌 !

@Lepo00 Lepo00 merged commit 4bb3ee3 into main Apr 14, 2026
20 checks passed
@Lepo00 Lepo00 deleted the fix/bool-diagnostics-value-serialization branch April 14, 2026 09:29
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