Repository navigation
Conversation
The d053317 Invoke refactor switched malformed-JSON headers from a warning+empty-dict fallback to raising ValueError, and a non-object JSON payload (e.g. an array) from being ignored to also raising. This turns user-config mistakes into uncaught component errors that break the whole agent run. This commit restores the pre-d053317 behavior: - Log a warning and return an empty header dict when self._param.headers fails to parse as JSON. - Log a warning and return an empty header dict when the parsed payload is not a JSON object (e.g. a list, number, or string). - Add a parametrized regression test covering both malformed JSON and a non-object JSON payload.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe Invoke component now ignores invalid or non-object header payloads, logs warnings, and sends requests with empty headers. Parametrized tests cover malformed JSON and JSON arrays. ChangesInvoke header handling
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Invoke now ignores malformed or non-object header JSON, logs a warning, and continues requests with empty headers. No current merge-blocking risk is identified. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. I’m a rabbit with headers held light, Comment |
6ba3i
left a comment
There was a problem hiding this comment.
A few points still look worth addressing before merge:
-
The Go implementation should be updated too.
Python now ignores malformed/non-object header JSON and continues without custom headers, butinternal/agent/component/invoke.gostill returns an error for the same inputs. Since both implementations serve the same Invoke component, they should follow the same behavior. -
Avoid logging the raw header value.
The new warning includesraw=%r, which can expose bearer tokens, API keys, cookies, or other secrets if the JSON is malformed. Logging the parse error alone should be enough. -
Python should also handle non-string header values.
json.loads()can raiseTypeErrorif headers arrive as an already-decoded dict or another non-string type. The backend does not strictly guarantee a string here. Accepting dicts directly and safely ignoring unsupported types would make the fallback complete.
|
could you please fix the issues raised in my comment ? |
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
now overlaps #19481 |
What problem does this PR solve?
The d053317 Invoke refactor (Fix: variable in doc generator, #14180) silently changed how malformed or non-object JSON in the
headersparameter is handled. Before that commit, Invoke would log a warning and fall back to an empty header dict; afterwards, both cases raiseValueError, which propagates out of_invokeand breaks the whole agent run whenever a user mistypes the headers field.This PR restores the previous tolerant behavior:
A parametrized regression test covers both branches.
Type of change
How to test
Run the unit test file directly (no live services needed):
17 tests pass (15 existing + 2 new).