Skip to content

Arguments validations (1/3): add arguments_schema field and preserve optional fields on program re-upload#2330

Draft
avilches wants to merge 6 commits into
mainfrom
arguments-validation-storage
Draft

Arguments validations (1/3): add arguments_schema field and preserve optional fields on program re-upload#2330
avilches wants to merge 6 commits into
mainfrom
arguments-validation-storage

Conversation

@avilches

@avilches avilches commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Add an arguments_schema field to programs so a function can declare a JSON Schema describing its valid arguments, and store it on upload. This is the storage layer for argument validation; the validation itself and the client SDK support land in follow-up PRs.

This also makes re-uploads non-destructive: re-uploading a function with only some fields no longer resets runner, dependencies, or env_vars to their defaults, and the entrypoint/image requirement now applies only when creating a function, not on update.

Details and comments

  • arguments_schema is a text field validated as JSON at the serializer level (schema semantics are checked later, when validating arguments against it).
  • On re-upload, optional fields are preserved when omitted, using None as the sentinel in the upload input dataclass.
  • New migration 0055_program_arguments_schema.py.

@avilches
avilches requested a review from a team as a code owner July 9, 2026 11:20
@avilches avilches changed the title Add arguments_schema field and preserve optional fields on program re-upload Arguments validations: add arguments_schema field and preserve optional fields on program re-upload Jul 9, 2026
@avilches avilches self-assigned this Jul 9, 2026
@avilches
avilches force-pushed the arguments-validation-storage branch from 70948d3 to d04cc53 Compare July 9, 2026 13:54
migrations.AddField(
model_name="program",
name="arguments_schema",
field=models.TextField(blank=True, default="{}", null=True),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I make the filed nullable in the db (with null=True), so it will survive to a deployment rollback in production. /cc @Tansito @ElePT

@avilches
avilches marked this pull request as draft July 9, 2026 13:59
@avilches

avilches commented Jul 9, 2026

Copy link
Copy Markdown
Contributor Author

Draft until deployment in production works

@avilches
avilches marked this pull request as ready for review July 13, 2026 12:09
@avilches

Copy link
Copy Markdown
Contributor Author

The PR is safe to merge: it adds a nullable field, so it is rollback compatible (old code inserting a program row just leaves the column NULL, which the read path treats as "no schema").

It also changes the /upload endpoint behaviour for the better. Before the PR, re-uploading a function to update it required sending entrypoint or image every time, and any optional field you left out (runner, dependencies, env_vars) was reset to its default. Now only the title is mandatory on update; every other field is preserved from the database when omitted. So to update a schema you only need to send the title plus the arguments_schema field.

@avilches avilches changed the title Arguments validations: add arguments_schema field and preserve optional fields on program re-upload Arguments validations [1/3]: add arguments_schema field and preserve optional fields on program re-upload Jul 14, 2026
@avilches
avilches marked this pull request as draft July 14, 2026 15:01
@avilches avilches changed the title Arguments validations [1/3]: add arguments_schema field and preserve optional fields on program re-upload Arguments validations (1/3): add arguments_schema field and preserve optional fields on program re-upload Jul 14, 2026
@avilches

Copy link
Copy Markdown
Contributor Author

Safe to merge to main since pentest finished

@avilches
avilches marked this pull request as ready for review July 17, 2026 07:33

@ElePT ElePT left a comment

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.

The PR mostly looks good, I just find the runner change a bit strange. In practice I think this affects very few users but given how the runner has proven to be complicated to use before, I want to make sure we don't add even more hidden behaviors (what's a hidden behavior I guess is another discussion we can have).

Comment on lines +120 to +121
if data.runner is not None:
instance.runner = data.runner

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.

I'm not convinced about preserving the runner value on re-upload. If someone omits runner, silently keeping fleets when they expected ray breaks job execution with no obvious error. The current SDK always sends runner anyway (it defaults to "ray"), so the only callers affected by this change are old SDK versions or direct API users, and for those, I think that falling back to ray is safer than preserving whatever was stored.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we send ray by default in case of re-upload? I think someone can reupload a fleet function without specifying and have errors.

@korgan00 korgan00 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@Tansito
Tansito marked this pull request as draft July 17, 2026 16:17
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.

3 participants