Skip to content

Conversation

EnergeticPulse
Copy link

@EnergeticPulse EnergeticPulse commented Oct 2, 2025

Contribution Checklist

  • Make sure that the pull request corresponds to a GITHUB issue.
  • Name the pull request in the form "[Bug] [http] Preserve nested JSON structure in request body"
  • Minor fixes should be named following this pattern: [hotfix] [docs] Fix typo in README. md doc.

Purpose of this pull request

This pull request fixes a bug in the HTTP connector where nested JSON request bodies (e.g., {"user": {"name": "Alice"}}) are incorrectly flattened into dot-separated keys like {“user->name": "Alice"} due to the use of ConfigFactory.parseString(). This breaks compatibility with APIs that expect structured JSON payloads. The fix replaces ConfigFactory with JsonUtils. parseObject() to preserve the original nested structure.

Does this PR introduce any user-facing change?

Yes.

  • Previous behavior: Nested JSON in the HTTP request body was flattened (e.g., {"a": {"b": 1}}{“a->b": "1"}).
  • New behavior: Nested JSON is preserved as-is (e.g., {"a": {"b": 1}} remains a nested map).aaaaa
    This change ensures the HTTP connector sends correctly structured JSON to downstream services, which is the expected behavior for most REST APIs. It is backward compatible for valid JSON inputs; invalid JSON bodies fall back to an empty map (same as before).

How was this patch tested?

  • Added unit tests in HttpClientProviderTest.java:
  • testFixedBodyParsingPreservesNestedJsonStructure(): verifies that nested objects, arrays, and primitives are correctly preserved after the fix.
  • Verified that all existing tests in seatunnel-connector-http still pass.
  • Manually tested with a sample HTTP sink configuration sending nested JSON to a mock server (confirmed correct payload structure).

Check list

@dybyte
Copy link
Contributor

dybyte commented Oct 4, 2025

Could you enable CI following the instructions?

@github-actions github-actions bot added the e2e label Oct 6, 2025
@EnergeticPulse
Copy link
Author

Could you enable CI following the instructions?

CI has been enabled, but I don't know why engine-v2-it (11, ubuntu-latest) keeps failing

@dybyte
Copy link
Contributor

dybyte commented Oct 7, 2025

You can find the details in the CI error log

return Collections.emptyMap();
}
try {
return JsonUtils.parseObject(body, new TypeReference<Map<String, Object>>() {});
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible that body is a list?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants