Skip to content

fix(trigger): keep webhook form/query integers exact and reject non-finite numbers - #44706

Merged
wylswz merged 1 commit into
langgenius:mainfrom
TemitopeKadri:fix/webhook-form-number-precision
Oct 28, 2026
Merged

wylswz merged 1 commit into
langgenius:mainfrom
TemitopeKadri:fix/webhook-form-number-precision

Conversation

@TemitopeKadri

Copy link
Copy Markdown
Contributor

Important

  1. Make sure you have read our contribution guidelines
  2. Ensure there is an associated issue
  3. Use the correct syntax to link this PR: Fixes #<issue number>.

Summary

Fixes #44705

Webhook Number parameters from query strings and form bodies (x-www-form-urlencoded / multipart/form-data) were converted with float() and then int(). That had two effects:

  • Integers above 253 were rounded.** For example, 1234567890123456789 became 1234567890123456768. So 64-bit IDs (snowflakes, bigints) reached the workflow as a different number than the caller sent. _convert_form_value now parses integers exactly with int() first, and only falls back to float() for decimals and exponents (19.99, 1e3).
  • nan, inf and overflowing values like 1e400 were accepted as numbers. _can_convert_to_number now requires a finite value, so these get the existing "Cannot convert ... to number" error. This matches the JSON body path, where orjson already rejects NaN; before, a form nan ended up as null once serialized.

The change is limited to api/services/trigger/webhook_service.py. Strings, booleans and the JSON body path are unchanged.

Screenshots

Input (Number param) Before After
1234567890123456789 1234567890123456768 1234567890123456789
9007199254740993 9007199254740992 9007199254740993
nan / inf accepted rejected: "Cannot convert 'nan' to number"
42, 19.99, 1e3 42, 19.99, 1000 unchanged

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've verified the change and added or updated tests where meaningful regression risk justifies coverage.
  • I've updated the documentation accordingly.
  • I ran make lint && make type-check (backend) and vp staged (frontend) to appease the lint gods

Tests: added parametrized cases to api/tests/unit_tests/services/trigger/test_webhook_service.py. Eight of the new cases fail on main and pass with this change, and 1e3 guards the existing behavior. The whole file passes (85 passed, 1 skipped), and ruff check / ruff format --check are clean.

🤖 Generated with Claude Code

From Claude Code

…inite numbers

Number parameters from query strings and form bodies went through float(),
so integers above 2**53 (64-bit IDs) were silently rounded, and nan/inf
were accepted. Parse integers exactly first and treat non-finite values as
invalid, matching the JSON body path, which already rejects NaN.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Oct 24, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-10-24 12:42:30.835335192 +0000
+++ /tmp/pyrefly_pr.txt	2026-10-24 12:42:20.759311978 +0000
@@ -6227,11 +6227,11 @@
 ERROR Argument `dict[str, dict[str, list[dict[str, bool | str]] | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.extract_and_validate_webhook_data` [bad-argument-type]
    --> tests/unit_tests/services/trigger/test_webhook_service.py:952:95
 ERROR Argument `dict[str, str | dict[str, str]]` is not assignable to parameter `webhook_data` with type `RawWebhookDataDict` in function `services.trigger.webhook_service.WebhookService._validate_http_metadata` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1212:61
+    --> tests/unit_tests/services/trigger/test_webhook_service.py:1232:61
 ERROR Argument `dict[str, dict[str, int] | dict[str, str]]` is not assignable to parameter `webhook_data` with type `RawWebhookDataDict` in function `services.trigger.webhook_service.WebhookService.build_workflow_inputs` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1224:59
+    --> tests/unit_tests/services/trigger/test_webhook_service.py:1244:59
 ERROR Argument `dict[str, dict[str, int | str]]` is not assignable to parameter `node_config` with type `NodeConfigDict` in function `services.trigger.webhook_service.WebhookService.generate_webhook_response` [bad-argument-type]
-    --> tests/unit_tests/services/trigger/test_webhook_service.py:1235:69
+    --> tests/unit_tests/services/trigger/test_webhook_service.py:1255:69
 ERROR Cannot find module `dify_graph.enums` [missing-import]
   --> tests/unit_tests/services/workflow/test_workflow_converter.py:36:5
 ERROR Cannot find module `dify_graph.model_runtime.entities.llm_entities` [missing-import]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 78.53% 78.53% +0.00%
Strict coverage 78.21% 78.21% +0.00%
Typed symbols 73,894 73,899 +5
Untyped symbols 20,284 20,284 0
Modules 3911 3911 0

@codecov

codecov Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.30%. Comparing base (2b35144) to head (f773eed).
⚠️ Report is 9 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #44706   +/-   ##
=======================================
  Coverage   89.30%   89.30%           
=======================================
  Files        5983     5984    +1     
  Lines      375012   375029   +17     
  Branches    76053    76053           
=======================================
+ Hits       334898   334915   +17     
  Misses      34078    34078           
  Partials     6036     6036           
Flag Coverage Δ
api 89.19% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wylswz
wylswz added this pull request to the merge queue Oct 28, 2026
Merged via the queue into langgenius:main with commit 2a99ac0 Oct 28, 2026
47 checks passed
@laipz8200 laipz8200 mentioned this pull request Nov 3, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Webhook Number params from query/form lose precision above 2**53 and accept nan/inf

2 participants