Skip to content

feat(mm): add editable source_url field to model config#8997

Open
Pfannkuchensack wants to merge 11 commits intoinvoke-ai:mainfrom
Pfannkuchensack:feat/source_url_model_manager
Open

feat(mm): add editable source_url field to model config#8997
Pfannkuchensack wants to merge 11 commits intoinvoke-ai:mainfrom
Pfannkuchensack:feat/source_url_model_manager

Conversation

@Pfannkuchensack
Copy link
Copy Markdown
Collaborator

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

  1. Open the Model Manager, select any model
  2. Click "Edit" - a new "Source URL" field should appear below the description
  3. Enter a URL (e.g. https://civitai.com/models/...), save
  4. In the view mode, the URL should appear as a clickable link below the source
  5. Models without a URL set should not show the field

Merge Plan

No special handling needed. The new source_url field is optional with a None default, stored in the JSON config column - no DB migration required. Existing model records are unaffected.

Checklist

  • The PR has a short but descriptive title, suitable for a changelog
  • Tests added / updated (if applicable)
  • ❗Changes to a redux slice have a corresponding migration
  • Documentation added / updated (if applicable)
  • Updated What's New copy (if doing a release after this PR)

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.
@github-actions github-actions bot added python PRs that change python files backend PRs that change backend files services PRs that change app services frontend PRs that change frontend files labels Mar 26, 2026
@Pfannkuchensack Pfannkuchensack changed the title feat(mm(: add editable source_url field to model config feat(mm): add editable source_url field to model config Mar 26, 2026
@joshistoast
Copy link
Copy Markdown
Collaborator

@Pfannkuchensack Looked over the PR and overall looks good, though I did manage to find something that should probably get addressed.

The source_url field accepts arbitrary text and does not go through any validation before rendering as a potentially invalid link. Could be a security liability if it's a javascript: uri scheme that could execute code (particularly for hosted forks).

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.

Copy link
Copy Markdown
Collaborator

@joshistoast joshistoast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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://")):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

<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://" />
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add type="url" here for some basic client-side validation until we put real effort into better overall model edit validation.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Pfannkuchensack and others added 5 commits April 14, 2026 02:37
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend PRs that change backend files frontend PRs that change frontend files python PRs that change python files services PRs that change app services v6.13.x

Projects

Status: 6.13.x Theme: MODELS

Development

Successfully merging this pull request may close these issues.

3 participants