Skip to content

fix: reject defaults for Path and File inputs - #3232

Closed
themanoj-025 wants to merge 1 commit into
replicate:mainfrom
themanoj-025:fix/reject-file-input-defaults
Closed

themanoj-025 wants to merge 1 commit into
replicate:mainfrom
themanoj-025:fix/reject-file-input-defaults

Conversation

@themanoj-025

Copy link
Copy Markdown

What

Path and File inputs are serialized as URLs (type: string, format: uri) in the schema, so a default that points at a local file can never be resolved by an API consumer. Today both Input(default=...) and bare signature defaults are accepted and silently produce a schema value that Replicate cannot use (reported in #606).

Changes

  • Reject any non-None default for Path/File inputs in _validate_input_constraints, covering Input(default=Path(...)) and string defaults alike.
  • Reject bare signature defaults (image: Path = Path("image.png")) in _create_input_field.
  • Document the restriction on Input(default=...).
  • Optional[Path] = None keeps working — only actual defaults are rejected.

Tests

Added four regression tests in python/tests/test_inspector.py: FieldInfo default, string default, raw signature default, and the allowed optional-without-default case.

$ uv run pytest python/tests -q
201 passed, 1 skipped

$ uv run ruff check ... && uv run ruff format --check ...
All checks passed!
3 files already formatted

Fixes #606

Path and File inputs are serialized as URLs in the schema, so a default
that points at a local file can never be resolved by an API consumer.
Reject such defaults on both the Input(default=...) path and bare
signature defaults, and document the restriction in Input().

Fixes replicate#606
@themanoj-025
themanoj-025 requested a review from a team as a code owner December 1, 2026 03:53
@themanoj-025

Copy link
Copy Markdown
Author

Closing this PR due to persistent CI/CLA issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disallow setting default for files/paths

1 participant