Skip to content

fix(json_process): apply replacements to root values - #4158

Open
Wang-MuFF wants to merge 1 commit into
langgenius:mainfrom
Wang-MuFF:fix/json-replace-root
Open

Wang-MuFF wants to merge 1 commit into
langgenius:mainfrom
Wang-MuFF:fix/json-replace-root

Conversation

@Wang-MuFF

@Wang-MuFF Wang-MuFF commented Oct 31, 2026 •

Copy link
Copy Markdown

Summary

Fixes #4157.

JSON Replace ignores the document returned by JSONPath.update(). Nested replacements mutate their parent, but a root query ($) returns a new document, leaving the original content unchanged.

Retain the returned document in value and string replacement modes. Add real-SDK tests, document root queries and bump JSON Process to 0.0.10. The locked SDK remains 0.10.2; its declared range now includes the template's required <0.11.0 boundary.

Release Notes

  • Fix JSON Replace ignoring replacements of the entire JSON value when the query is $, including string replacement with Decode Value enabled.

Change Type

  • Documentation / non-plugin change
  • Non-LLM plugin (tools, extensions, datasource, etc.)
  • LLM plugin

Screenshots / Videos

Actual tool results from the original source and the packaged fix:

Operation Before After
Replace {"before": 1} at $ with decoded {"after": 2} {"before": 1} {"after": 2}
Replace before with after in root JSON string "before" "before" "after"

LLM Plugin Checklist

Not applicable.

Version

  • Bumped top-level version in manifest.yaml.
  • Declared dify_plugin>=0.10.2,<0.11.0 in pyproject.toml; regenerated uv.lock without changing dependency versions.

Testing

  • Clean plugin environment matching the manifest's Python 3.12 and frozen dependencies: 17 tests passed. Ten regression cases fail on the original implementation; seven preservation cases pass there.
  • All 17 tests also passed with the declared minimum jsonpath-ng==1.8.0.
  • Official Dify CLI v0.6.13 packaged the plugin; all 17 tests passed again in a fresh environment from the unpacked artifact.
  • Started the packaged plugin in serverless mode: /health returned 200 and both root replacement modes returned the expected results over HTTP. The same HTTP assertion fails on the unchanged base.
  • Black and Ruff pass for the new tests; git diff --check passes. The source's six existing Ruff diagnostics are identical on the immutable base and this branch.
  • Local deployment — full Dify application not run.
  • SaaS (cloud.dify.ai)
uv run --frozen --project tools/json_process --with pytest==9.0.3 pytest tools/json_process/tests -q
Coverage Cases
Root objects, arrays, strings, numbers, booleans and null 6
Root string replacement and decoded replacement 2
ASCII/Unicode output 2
Nested replacements, multiple matches, key replacement and no matches 7

This branch has not been deployed

No deployments
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.

JSON Replace silently ignores replacements of the root JSON value

1 participant