feat(dify): identify plugin requests with X-TF-Client-Name/Version - #36
Open
londondavila wants to merge 4 commits into
Open
feat(dify): identify plugin requests with X-TF-Client-Name/Version#36londondavila wants to merge 4 commits into
londondavila wants to merge 4 commits into
Conversation
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
|
Warning Review limit reachedNext included review available in 51 minutes. View limit detailsLimit details: You’ve used all 2 included reviews currently available. Your 52 included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Essentials Run ID: 📒 Files selected for processing (7)
Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Search and Fetch calls from the Dify plugin arrive with
client_namenull, so in telemetry they sit inside the untaggedrequest_origin=apibucket indistinguishable from a hand-written script. Runs were already attributed through theapi_integrationpayload field, but search/fetch and the GET tools have no body to carry it. The server readsX-TF-Client-Name/X-TF-Client-Versionon every route (request-source.ts:160), and this plugin hitsagent.tinyfish.aidirectly._api_headersaddsX-TF-Client-Name: dify(bare token, same as the existingapi_integration) andX-TF-Client-Versionfrommanifest.yaml; both call sites (_tf_request,run_ssestream) already use itPLUGIN_VERSION = yaml.safe_load(manifest)["version"]— pyyaml is the loader the Dify daemon uses on this file and was already a hard transitive dep; now explicit inrequirements.txt. Path resolution verified against the daemon's packager/loader:manifest.yamlat the.difypkgroot,tools/one level below, in every runtime modeversionfields, matching prior bumps.difyignore:tests/, so the new tests don't ship in the marketplace artifacttests/test_headers.py: header contract;PLUGIN_VERSIONis a real semver present at column 0 of the manifestX-TF-Request-Origindeliberately unset —apistays the transportPrerequisites / footguns
dify/.github/workflows/plugin-publish.yml, not the repo root, so GitHub ignores it; marketplace republish is a manual step. Pre-existing, out of scope here, worth its own fix.httpxis only transitive.uv run --with pytest --with httpx --with pyyaml pytest dify/tests.client_nameis self-reported. Analytics only, never auth or billing.tools/run_*.py/get_run.py/list_runs.pyare pre-existing and untouched.Testing:
pytest2 passed, fromdify/and from the repo root.🤖 Generated with Claude Code
https://claude.ai/code/session_0138Vn8E8TfZkUWd3StqDgjp