cog
0d248cc4 - fix: treat `Secret = Input(default=None)` as optional in static schema gen (#2949)

Commit
34 days ago
fix: treat `Secret = Input(default=None)` as optional in static schema gen (#2949) * fix: schema gen casing / default null issues Signed-off-by: Mark Phelps <mphelps@cloudflare.com> * perf: install user packages before SDK in cog-base Dockerfile Reorder the cog-base-image Dockerfile layers so user python_packages (torch, diffusers, etc.) are installed before the cog SDK/coglet. This means changing the SDK wheel (via COG_SDK_WHEEL, --cog-ref, or version bumps) no longer invalidates the Docker cache for expensive user dependencies. Previously, an SDK change would force a full rebuild of multi-GB packages like torch. The non-cog-base-image path already had this ordering. Now both paths are consistent. * fix: treat `Secret = Input(default=None)` as optional in static schema gen `api_key: Secret = Input(default=None)` is a widespread, documented idiom for an optional credential that falls back to a proxy key when the caller omits it. The static schema generator was applying the "DefaultNone on a non-nullable field is not a real default" rule (originally intended for `seed: int = Input(default=None)`) uniformly, which put the Secret in `required` and dropped both `nullable: true` and the null default. The Replicate API validator then 422'd every request that didn't supply the supposedly-optional key. Exempt `TypeSecret` with `Required` repetition and explicit `DefaultNone` from that rule. The field now emits `nullable: true` and `default: null` and is dropped from `required` — matching the `Optional[Secret] = Input(default=None)` spelling and 0.16.x behavior. `Secret` without a `default=` kwarg stays required, and `seed: int = Input(default=None)` is unchanged. * chore: merge main Signed-off-by: Mark Phelps <mphelps@cloudflare.com> --------- Signed-off-by: Mark Phelps <mphelps@cloudflare.com> Signed-off-by: Mark Phelps <209477+markphelps@users.noreply.github.com>
Author
Parents
Loading