Skip to content

feat(model-runtime): retain credential form schema help from manifests - #243

Open
dparkmit24 wants to merge 1 commit into
langgenius:mainfrom
dparkmit24:credential-form-schema-help
Open

feat(model-runtime): retain credential form schema help from manifests#243
dparkmit24 wants to merge 1 commit into
langgenius:mainfrom
dparkmit24:credential-form-schema-help

Conversation

@dparkmit24

Copy link
Copy Markdown

Important

  1. Make sure you have read our contribution guidelines
  2. Search existing issues and pull requests to confirm this change is not a duplicate
  3. Open or identify the issue this pull request resolves or advances
  4. Use a Conventional Commits title for this pull request, and mark breaking changes with !
  5. Remember that the pull request title will become the squash merge commit message
  6. If CLA Assistant prompts you, sign CLA.md in the pull request conversation

Related Issue

No graphon issue exists for this. This PR is the graphon half of a cross-repo change whose first half has already merged: langgenius/dify-plugin-daemon#774 (merged 2026-08-04). I searched graphon's open and merged PRs and its issues for provider_entities, CredentialFormSchema and credential help and found no duplicate — happy to open a tracking issue first if maintainers prefer that order.

Summary

A plugin manifest's per-field help currently cannot reach any consumer, because graphon discards it.

The chain, in order:

  1. Merged. dify-plugin-daemon#774 added Help to the daemon's ModelProviderCredentialFormSchema, so a manifest's per-field help now survives unmarshal in the daemon and reaches the management-API declaration.
  2. This PR. graphon's CredentialFormSchema has no help field. It sets no ConfigDict, so pydantic v2's default extra="ignore" applies and the key is dropped silently on unmarshal. Whatever the daemon sends, graphon throws it away.
  3. Still unfiled. The Dify frontend needs to map helptooltip for model-provider credentials. That work is blocked until this lands, since today the value never gets far enough to be mapped.

The change

Two lines.

CredentialFormSchema gains help: I18nObject | None = None. This mirrors a shape this codebase already uses: ParameterRule in model_runtime/entities/model_entities.py already carries help: I18nObject | None = None, in the same position relative to label and type. I18nObject was already imported in provider_entities.py.

The slim package loader forwards the key. SlimPackageLoader._convert_credential_form_schema builds CredentialFormSchema field by field from the raw manifest dict rather than validating it, so it dropped help independently of the entity definition — adding the field alone would have left this path still silently discarding the value. The added line is identical in form to what _convert_parameter_rule in the same file already does for ParameterRule.help: help=self._convert_optional_i18n(value.get("help")).

I traced the parsed schema to its other consumers to check for any further drop point. schema_validators/common_validator.py accesses fields by attribute name only, and ProviderCredentialSchema / ModelCredentialSchema simply hold list[CredentialFormSchema]; neither enumerates fields positionally or exhaustively, so neither is disturbed by an added optional field and neither drops the value. After these two lines there is no remaining drop point inside graphon.

Scope and limits

  • Additive and optional. help defaults to None; _convert_optional_i18n returns None for a missing key. A manifest that parses today parses identically and behaves identically. No required field, no changed default, no new validation that could reject anything.
  • url deliberately omitted. #774 also added URL for daemon parity, and its body offered to drop it if maintainers preferred the minimal change. Nothing in graphon consumes a per-field credential url; the provider-level help link is already modelled separately as ProviderHelpEntity {title, url} on ProviderEntity.help. Adding an unused per-field url would introduce a second convention for the same concept. Glad to add it if you want exact parity.
  • This does not complete the feature. Step 3 above (the frontend helptooltip mapping) is still unfiled and lives in the Dify repo. This PR unblocks it.

Tests

  • tests/model_runtime/test_provider_entities.py (new) — a manifest fragment carrying help round-trips through CredentialFormSchema and is retained, including when nested inside ProviderCredentialSchema; and a fragment with no help still parses with help is None.
  • tests/dsl/test_slim_package_loader.py — a plugin manifest declaring help on one credential field and not on another loads through SlimPackageLoader with the value retained on the first and None on the second.

Each of the two source lines was verified load-bearing by reverting it in isolation and confirming the corresponding tests fail, then restoring. Full suite: 706 passed, 0 failed (702 before this change, plus the 4 added here). ruff format --check, ruff check and ty check all clean.

Disclosure: this change was prepared with AI assistance (Claude). I have reviewed the diff, the end-to-end trace and the test results myself and take responsibility for their correctness.

Checklist

  • This pull request links the issue it resolves or advances — no graphon issue exists; it advances the merged dify-plugin-daemon#774, linked above. Will file one if preferred.
  • This pull request title follows Conventional Commits, and any breaking change is marked with !
  • If CLA Assistant prompted me, I signed CLA.md in the pull request conversation

`dify-plugin-daemon#774` (merged 2026-08-04) added `Help` to the daemon's
`ModelProviderCredentialFormSchema`, so a plugin manifest's per-field `help`
now reaches graphon. `CredentialFormSchema` had no `help` field, and with
pydantic v2's default `extra="ignore"` the key was discarded on unmarshal.

`ParameterRule` in `model_entities.py` already carries
`help: I18nObject | None`, so this mirrors the shape this codebase
already uses.

The slim package loader builds `CredentialFormSchema` field by field, so it
dropped `help` independently of the entity definition; it now forwards the
key the same way `_convert_parameter_rule` already does.

Both changes are additive and optional: manifests that parse today are
unaffected.
@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. enhancement New feature or request labels Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant