openai/openai-python · error · ValueError

Expected a non-empty value for `fine_tuning_job_id` but rece

Error message

Expected a non-empty value for `fine_tuning_job_id` but received {fine_tuning_job_id!r}

What it means

The sync FineTuningJobs.Checkpoints.list method requires a non-empty fine_tuning_job_id path parameter and checks it before requesting /fine_tuning/jobs/{id}/checkpoints. None or "" raises ValueError client-side.

Source

Thrown at src/openai/resources/fine_tuning/jobs/checkpoints.py:73

    ) -> SyncCursorPage[FineTuningJobCheckpoint]:
        """
        List checkpoints for a fine-tuning job.

        Args:
          after: Identifier for the last checkpoint ID from the previous pagination request.

          limit: Number of checkpoints to retrieve.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not fine_tuning_job_id:
            raise ValueError(f"Expected a non-empty value for `fine_tuning_job_id` but received {fine_tuning_job_id!r}")
        return self._get_api_list(
            path_template("/fine_tuning/jobs/{fine_tuning_job_id}/checkpoints", fine_tuning_job_id=fine_tuning_job_id),
            page=SyncCursorPage[FineTuningJobCheckpoint],
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                query=maybe_transform(
                    {
                        "after": after,
                        "limit": limit,
                    },
                    checkpoint_list_params.CheckpointListParams,
                ),
                security={"bearer_auth": True},
            ),
            model=FineTuningJobCheckpoint,

View on GitHub (pinned to 9917c6e28e)

Solutions

  1. Pass the job ID string, e.g. `job.id` from client.fine_tuning.jobs.create(...)
  2. Assign and check the ID right after job creation
  3. If reading from config, fail fast with a clear message when it is missing

Example fix

# before
job = client.fine_tuning.jobs.create(...)
client.fine_tuning.jobs.checkpoints.list(fine_tuning_job_id=None)
# after
client.fine_tuning.jobs.checkpoints.list(fine_tuning_job_id=job.id)
Defensive patterns

Strategy: validation

Validate before calling

if not fine_tuning_job_id:
    raise ValueError("fine_tuning_job_id is required")

Type guard

def is_job_id(v: object) -> bool:
    return isinstance(v, str) and v.startswith("ftjob-")

Prevention

When it happens

Trigger: Calling `client.fine_tuning.jobs.checkpoints.list(fine_tuning_job_id=None)`, typically when a created job returned no ID or a variable was never assigned.

Common situations: Using the response object instead of response.id; job creation failed earlier and the error was swallowed; reading the job ID from env/config that is unset.

Related errors


AI-assisted analysis of openai/openai-python@9917c6e28e (2026-08-28). Data as JSON: /api/errors/5dba324e7d87cf43. Report an issue: GitHub.