Page MenuHomePhabricator

[jobs-api] handle non-passed arguments and defaults consistently
Closed, ResolvedPublic

Description

Currently there's no clear way to handle arguments that are not passed, or returning information with/without defaults.

This will become simpler when we have storage, but for now, the idea is:

  • For input
    • In API the models, set the defaults to the values we want to be defaults
    • In the Core models, set the default to the same
    • When transforming from API -> Core models, exclude unset fields from API (model_dump(exclude_unset=True))
  • When fetching the job from k8s
    • Don't pass to the model any of the fields if they match the defaults (this breaks slightly idempotence, because if the user explicitly passed a value that matches the default, it will be lost as a default, but that will be sorted once we have storage)
  • For output
    • Add a new parameter include_unset: bool, default to true, that:
      • If passed as true (default), will return the object with all the fields that were not passed and set to defaults on job creation (ex. for jobs list/show)
      • If passed as false, will exclude the fields that were not passed when creating the job and set to their default values (ex. for job dumps or config generate)

Event Timeline

dcaro changed the task status from Open to In Progress.Aug 25 2025, 1:16 PM
dcaro moved this task from Next Up to In Progress on the Toolforge (Toolforge iteration 23) board.

group_203_bot_f4d95069bb2675e4ce1fff090c1c1620 opened https://gitlab.wikimedia.org/repos/cloud/toolforge/toolforge-deploy/-/merge_requests/952

jobs-api: bump to 0.0.411-20250903113356-7dfdec3e

dcaro moved this task from In Progress to Done on the Toolforge (Toolforge iteration 24) board.