Skip to content

fix: map NaN/Infinity float columns to JSON null instead of failing the workflow#144

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-nan-infinity-float-values
Draft

fix: map NaN/Infinity float columns to JSON null instead of failing the workflow#144
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-nan-infinity-float-values

Conversation

Copilot AI commented May 5, 2026

Copy link
Copy Markdown

float4/float8 columns containing NaN or ±Infinity caused the entire workflow to fail, since serde_json::Number::from_f64 returns None for non-finite values. This meant $result.nan_col-style substitutions were broken — either the column was missing or the instance was in failed state.

Changes

  • src/activities/execute_sql.rsFLOAT4/FLOAT8 decode branches now return Ok(serde_json::Value::Null) for non-finite values. After the finiteness guard, from_f64 is guaranteed to succeed, so the dead error path is replaced with .unwrap_or_else(|| panic!(...)) (value included in message). Updated module-level type table and decode_column docstring accordingly.

  • tests/e2e/sql/21_typed_results.sql — Test 11 rewritten: queries NaN, Infinity, and a finite column together; asserts the instance completes, that nan_col/inf_col appear as JSON null (key present), and that the finite column remains a JSON number.

// Before: non-finite → Err → instance fails
if v.is_nan() || v.is_infinite() {
    Err(format!("FLOAT8 column '{col_name}' contains non-finite value (NaN or Inf)"))
}

// After: non-finite → null → instance continues
if v.is_nan() || v.is_infinite() {
    Ok(serde_json::Value::Null)
}

Copilot AI and others added 3 commits May 5, 2026 13:42
When serde_json::Number::from_f64() returns None (for NaN / ±Infinity),
return serde_json::Value::Null so the column is present in the result
JSON with a null value rather than causing the workflow to fail.

- FLOAT4 and FLOAT8 branches now return Ok(Null) for non-finite values
- Update module-level type table: float4/float8 NaN/Inf → null
- Update decode_column docstring accordingly
- Update E2E test 11 in 21_typed_results.sql to assert completed status
  and verify nan_col/inf_col are JSON null while finite columns remain numbers

Agent-Logs-Url: https://github.com/microsoft/pg_durable/sessions/d5483b1c-7ab7-41b4-83b5-736e9972e137

Co-authored-by: pinodeca <32303022+pinodeca@users.noreply.github.com>
…Inf guard

After the is_nan()/is_infinite() guard, from_f64() is guaranteed to
succeed for finite values. Replace the if-let/else-err pattern with
.expect() to eliminate the dead error path identified by code review.

Agent-Logs-Url: https://github.com/microsoft/pg_durable/sessions/d5483b1c-7ab7-41b4-83b5-736e9972e137

Co-authored-by: pinodeca <32303022+pinodeca@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix bug causing NaN and Infinity float values to drop columns fix: map NaN/Infinity float columns to JSON null instead of failing the workflow May 5, 2026
Copilot AI requested a review from pinodeca May 5, 2026 13:46
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.

Bug: NaN and Infinity float values silently drop the column from results

2 participants