Skip to content

PromptVersion.published_at is required, so draft and other non-live versions fail to deserialize #1

Description

@anxkhn

PromptVersion.published_at is generated as a required, non-nullable datetime, but the field is null for any version that was never set to live. Its own description says so ("Timestamp when status was set to live. Null if draft."). When the server returns published_at: null, PromptVersion.from_dict raises a pydantic ValidationError, so the SDK cannot deserialize a version unless its status is live.

Reproduction

from px0.models.prompt_version import PromptVersion

PromptVersion.from_dict({
    "id": "ver_1",
    "prompt_id": "prm_1",
    "version": 1,
    "template": "Hello {{.name}}!",
    "status": "draft",
    "created_at": "2024-01-01T00:00:00Z",
    "published_at": None,
    "tags": [],
})
pydantic_core._pydantic_core.ValidationError: 1 validation error for PromptVersion
published_at
  Input should be a valid datetime [type=datetime_type, input_value=None, input_type=NoneType]

Impact

published_at is null for every version that is not currently live (draft, stable, archived). Because the wrapper models embed PromptVersion, this breaks the endpoints that return versions:

  • create_version returns a draft, so its own response cannot be parsed.
  • promote_version (draft -> stable) returns a version that was never live.
  • duplicate_version returns a draft.
  • get_version / archive_version on any non-live version.
  • list_versions fails entirely if a single element is non-live, since ListVersions200Response.versions is List[PromptVersion].

Root cause and fix

The response schema marks published_at required and non-nullable. APIKey.last_used_at has the same "Null if never used" semantics and is correctly Optional[datetime] = None, which is the shape published_at should have. In the OpenAPI document, published_at should be nullable: true and dropped from the schema's required list; the generator then emits Optional[datetime] = None.

I have a PR that applies the equivalent change to the generated model and doc, with regression tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions