Skip to content

fix(invoke): tolerate invalid headers across runtimes - #19481

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
6ba3i:fix/invoke-header-tolerance
Sep 11, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
6ba3i:fix/invoke-header-tolerance

Conversation

@6ba3i

@6ba3i 6ba3i commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

Invalid or malformed headers are now ignored safely. Valid headers and variable interpolation continue to work.
based on #19184

@6ba3i
6ba3i requested a review from wangq8 September 10, 2026 05:54
@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 2a1f0eb5-015d-4641-98ab-9a15915e5d6f

📥 Commits

Reviewing files that changed from the base of the PR and between 3dbb4ce and 0185d9e.

📒 Files selected for processing (4)
  • agent/component/invoke.py
  • internal/agent/component/invoke.go
  • internal/agent/component/invoke_test.go
  • test/testcases/test_web_api/test_canvas_app/test_invoke_component_unit.py

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Invoke header parsing now handles empty, invalid, unsupported, and non-object inputs without raising errors. Python preserves dictionary handling and variable substitution. Go adds equivalent tolerant parsing and logging tests.

Changes

Invoke header handling

Layer / File(s) Summary
Python header validation
agent/component/invoke.py, test/testcases/test_web_api/test_canvas_app/test_invoke_component_unit.py
_build_headers returns empty headers for invalid inputs, accepts dictionaries and JSON objects, avoids logging raw values, and interpolates variables in valid dictionaries.
Go header validation
internal/agent/component/invoke.go, internal/agent/component/invoke_test.go
invokeHeaders returns nil headers without errors for invalid inputs. Tests cover valid maps, invalid values, and protection against logging raw payloads.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: jinhai-cn, hz-186

Merge Risk: ⚪ Minimal · up to 0185d

Invoke header parsing now ignores malformed configurations instead of failing execution while retaining valid headers and Python variable interpolation. The covered behavior is ready to merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: invoke header parsing now tolerates invalid headers across runtimes.
Description check ✅ Passed The description includes the required Summary section and accurately states that invalid headers are ignored while valid headers and variable interpolation continue to work.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit checks each header’s shape,
And leaves bad tokens in escape.
Maps pass through with care and grace,
Secrets stay out of logs in place.
The Invoke paths now safely hop,
While parsing errors gently stop.

Comment @coderabbitai help to get the list of available commands.

@6ba3i 6ba3i added the ci Continue Integration label Sep 10, 2026
@codecov

codecov Bot commented Sep 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 37.29%. Comparing base (48f6cbf) to head (0185d9e).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #19481   +/-   ##
=======================================
  Coverage   37.29%   37.29%           
=======================================
  Files          54       54           
  Lines       15354    15354           
  Branches      119      119           
=======================================
  Hits         5727     5727           
  Misses       9601     9601           
  Partials       26       26           

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is an AI review comment.

Summary: Tolerates invalid/malformed headers by ignoring them (with a WARNING log) instead of failing the invoke, across both the Python and Go runtimes. Good test coverage, and the tests explicitly guard against leaking raw header values (secrets) into logs.

Verified:

  • Python: None/empty string → {}; a dict is now accepted directly (with string values interpolated via _resolve_header_text); invalid JSON → warn + {}; non-object JSON (array/scalar/null) → warn + {}; unsupported type → warn + {}. json/logging are imported, and the warning only logs line/column — never the payload.
  • Go: nil/empty/unsupported type/invalid JSON/non-object → warn + nil (no error). Secret payload is never logged (TestInvokeHeadersDoesNotLogRawPayload).
  • Tests cover malformed JSON, empty, array, scalar, null, unsupported type, object, and direct map, plus interpolation and secret-leak checks in Python.

Points to consider (non-blocking):

  1. Behavior change: previously invalid headers caused the invoke to fail with a clear error; now they are silently dropped (server-side WARNING only). A user with a malformed Authorization header will now send an unauthenticated request and likely hit a confusing downstream 401/403 rather than an immediate config error. Consider surfacing the warning to the canvas user (e.g. a warning output channel) instead of only the server log — or confirm this silent tolerance is the intended UX.
  2. In Go, invokeHeaders can no longer return a non-nil error, so the if err != nil { return nil, err } branch at the call site is now effectively dead code. Minor — consider dropping the error return (or leave for symmetry).
  3. TestInvokeHeadersDoesNotLogRawPayload mutates the global logger via zap.ReplaceGlobals (restored in cleanup). Fine today since no test in this package uses t.Parallel(), but it's global state — be mindful if parallelism is introduced later.

Overall LGTM — no security regressions; the secret-logging guard is a nice touch.

This is an AI review comment.

@wangq8
wangq8 merged commit 681f418 into infiniflow:main Sep 11, 2026
7 checks passed
@6ba3i
6ba3i deleted the fix/invoke-header-tolerance branch September 22, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants