feat(mm): add editable source_url field to model config#8997
feat(mm): add editable source_url field to model config#8997Pfannkuchensack wants to merge 11 commits intoinvoke-ai:mainfrom
Conversation
Allow users to store a URL (e.g. download page or model page) on any model, independent of the original installation source. The URL is editable in the model edit form and displayed as a clickable link in the model header view.
|
@Pfannkuchensack Looked over the PR and overall looks good, though I did manage to find something that should probably get addressed. The The model edit panel doesn't seem to have much validation at all for inputs, maybe that could be addressed in a later PR with a proper overall zod configuration and validation step. |
joshistoast
left a comment
There was a problem hiding this comment.
A couple things we can do to tighten up validation a bit, then I'd say it's good to go
| @classmethod | ||
| def validate_source_url(cls, v: str | None) -> str | None: | ||
| if v is not None and v != "": | ||
| if not v.startswith(("https://", "http://")): |
There was a problem hiding this comment.
GPT rose a concern for this and model_records_base.py, if you call .startswith() inside a mode="before" validator without first checking the raw value is a string. A PATCH body like {"source_url": 123} will hit AttributeError instead of a normal validation error, which is likely to surface as a 500 instead of a clean 4xx.
| <Flex gap="4" alignItems="center"> | ||
| <FormControl flexDir="column" alignItems="flex-start" gap={1}> | ||
| <FormLabel>{t('modelManager.sourceUrl')}</FormLabel> | ||
| <Input {...form.register('source_url')} size="md" placeholder="https://" /> |
There was a problem hiding this comment.
We should add type="url" here for some basic client-side validation until we put real effort into better overall model edit validation.
Guard the pydantic `mode="before"` validator with an isinstance check
so PATCH bodies like `{"source_url": 123}` surface as a 422 instead of
a 500 from AttributeError on `.startswith()`. Also set `type="url"` on
the model edit input for basic browser-level validation.
…annkuchensack/InvokeAI into feat/source_url_model_manager
Summary
Allow users to store a URL (e.g. download page or model page) on any model, independent of the original installation source. The URL is editable in the model edit form and displayed as a clickable link in the model header view.
Related Issues / Discussions
https://discord.com/channels/1020123559063990373/1486083997355343923
QA Instructions
https://civitai.com/models/...), saveMerge Plan
No special handling needed. The new
source_urlfield is optional with aNonedefault, stored in the JSON config column - no DB migration required. Existing model records are unaffected.Checklist
What's Newcopy (if doing a release after this PR)