Skip to content

feat(dify): identify plugin requests with X-TF-Client-Name/Version - #36

Merged
londondavila merged 6 commits into
mainfrom
london/dify-client-headers
Sep 8, 2026
Merged

feat(dify): identify plugin requests with X-TF-Client-Name/Version#36
londondavila merged 6 commits into
mainfrom
london/dify-client-headers

Conversation

@londondavila

@londondavila londondavila commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

dify search/fetch/GET calls land with client_name null, indistinguishable from raw curl in request_origin=api. api_integration rides run payloads only; GET and search/fetch have no body. server reads X-TF-Client-Name / X-TF-Client-Version on every route (request-source.ts:160).

  • _api_headers sends X-TF-Client-Name: dify + X-TF-Client-Version from manifest.yaml. both outbound sites (_tf_request, run_sse stream) already use it
  • PLUGIN_VERSION = yaml.safe_load(manifest)["version"]. pyyaml already transitive via dify_plugin (pyyaml>=6.0.3), now explicit
  • 0.0.4 → 0.0.5, both manifest version fields
  • .difyignore: tests/, keeps them out of .difypkg
  • README: dify back in header-contract table
  • X-TF-Request-Origin unset. api is transport, server derives it

notes

  • new traffic only. existing installs stay unattributed till users update
  • dify publish workflow never runs. sits at dify/.github/workflows/plugin-publish.yml, not repo root, so GitHub ignores it. marketplace republish manual. pre-existing, own fix
  • no dify CI. run: uv run --with pytest --with httpx --with pyyaml pytest dify/tests
  • client_name self-reported. analytics only, never auth or billing
  • ruff findings in tools/run_*.py, get_run.py, list_runs.py pre-existing, untouched

londondavila and others added 4 commits September 1, 2026 11:39
Search and Fetch calls from this plugin land in TinyFish telemetry as
untagged request_origin=api. Runs were already tagged via the
api_integration payload field, but search/fetch have no payload to carry
it. The server reads X-TF-Client-Name / X-TF-Client-Version on every route.

- _api_headers adds X-TF-Client-Name: tinyfish-dify and
  X-TF-Client-Version read from manifest.yaml; both call sites
  (_tf_request and run_sse's stream) already use it
- tools/constants.PLUGIN_VERSION parsed from the manifest so the header
  cannot drift from the published version
- bump 0.0.4 → 0.0.5 (both manifest version fields, matching prior bumps)
- tests/test_headers.py: header contract and version/manifest agreement

X-TF-Request-Origin deliberately unset: `api` stays the transport.
Attributes new traffic only; needs a marketplace republish.

Testing: pytest 2 passed. Repo has no dify lint/test CI; ruff findings in
untouched tool files are pre-existing.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138Vn8E8TfZkUWd3StqDgjp
Review fixes. The packager honors .difyignore only, so tests/ was shipping in
the marketplace artifact. The manifest test re-parsed the file the same way
the constant does and opened it relative to cwd, so it could only fail by
being run from the wrong directory.

- .difyignore: tests/
- test asserts a real semver and that the manifest carries it, path resolved
  from __file__
- comment: request_origin stays `api`; what changes is client_name

Testing: pytest 2 passed from dify/ and from the repo root.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138Vn8E8TfZkUWd3StqDgjp
The substring check also matched the indented meta.version line.

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138Vn8E8TfZkUWd3StqDgjp
Aligns X-TF-Client-Name with the repo contract (bare token, same as
api_integration) and replaces the hand-rolled version scanner with
yaml.safe_load — pyyaml is already a hard dependency of dify_plugin and is
the loader the Dify daemon uses on the same file.

- X-TF-Client-Name: dify
- constants: yaml.safe_load(manifest)["version"], 0+unknown on any failure
- requirements: pyyaml explicit instead of transitive
- test: column-0 anchor on the manifest check

Testing: pytest 2 passed (uv run --with pytest --with httpx --with pyyaml).

Co-Authored-By: Claude Code <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138Vn8E8TfZkUWd3StqDgjp
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The Dify plugin now loads its version from manifest.yaml and falls back to 0+unknown when loading fails. API requests include the API key, X-TF-Client-Name, and X-TF-Client-Version headers. Tests verify header values and version consistency. The manifest version is 0.0.5, PyYAML is required, tests are excluded from Dify packages, and the shared documentation includes dify as a client token.

Priority: ⬇️ Low — Defer this Dify plugin metadata change because it adds client-identification headers and version packaging without supplied evidence of broader product impact.

Merge Risk: 🟡 Moderate · up to 29de3

The plugin manifest may be rejected or misinterpreted by Dify. Restore the manifest-format version before merging.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly identifies the main change: adding Dify client name and version headers to plugin requests.
Description check ✅ Passed The description directly explains the header changes, version source, version bump, packaging update, documentation update, testing, and deployment limitations.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch london/dify-client-headers

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

londondavila and others added 2 commits September 8, 2026 10:28
#35 dropped `dify` from the `X-TF-Client-Name` row because it did not send the
headers; this PR is the one that makes it comply.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nw7GKwVBvSXErUW8wkxaYD
coderabbitai[bot]

This comment was marked as resolved.

@londondavila
londondavila merged commit 6c40641 into main Sep 8, 2026
3 checks passed
@londondavila
londondavila deleted the london/dify-client-headers branch September 8, 2026 16:44
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.

2 participants