feat(model-runtime): retain credential form schema help from manifests - #243
Open
dparkmit24 wants to merge 1 commit into
Open
feat(model-runtime): retain credential form schema help from manifests#243dparkmit24 wants to merge 1 commit into
dparkmit24 wants to merge 1 commit into
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.
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.
Important
!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,CredentialFormSchemaand credentialhelpand found no duplicate — happy to open a tracking issue first if maintainers prefer that order.Summary
A plugin manifest's per-field
helpcurrently cannot reach any consumer, because graphon discards it.The chain, in order:
dify-plugin-daemon#774addedHelpto the daemon'sModelProviderCredentialFormSchema, so a manifest's per-fieldhelpnow survives unmarshal in the daemon and reaches the management-API declaration.CredentialFormSchemahas nohelpfield. It sets noConfigDict, so pydantic v2's defaultextra="ignore"applies and the key is dropped silently on unmarshal. Whatever the daemon sends, graphon throws it away.help→tooltipfor 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.
CredentialFormSchemagainshelp: I18nObject | None = None. This mirrors a shape this codebase already uses:ParameterRuleinmodel_runtime/entities/model_entities.pyalready carrieshelp: I18nObject | None = None, in the same position relative tolabelandtype.I18nObjectwas already imported inprovider_entities.py.The slim package loader forwards the key.
SlimPackageLoader._convert_credential_form_schemabuildsCredentialFormSchemafield by field from the raw manifest dict rather than validating it, so it droppedhelpindependently 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_rulein the same file already does forParameterRule.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.pyaccesses fields by attribute name only, andProviderCredentialSchema/ModelCredentialSchemasimply holdlist[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
helpdefaults toNone;_convert_optional_i18nreturnsNonefor 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.urldeliberately omitted. #774 also addedURLfor daemon parity, and its body offered to drop it if maintainers preferred the minimal change. Nothing in graphon consumes a per-field credentialurl; the provider-level help link is already modelled separately asProviderHelpEntity {title, url}onProviderEntity.help. Adding an unused per-fieldurlwould introduce a second convention for the same concept. Glad to add it if you want exact parity.help→tooltipmapping) 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 carryinghelpround-trips throughCredentialFormSchemaand is retained, including when nested insideProviderCredentialSchema; and a fragment with nohelpstill parses withhelp is None.tests/dsl/test_slim_package_loader.py— a plugin manifest declaringhelpon one credential field and not on another loads throughSlimPackageLoaderwith the value retained on the first andNoneon 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 checkandty checkall 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
dify-plugin-daemon#774, linked above. Will file one if preferred.!