Category: bug Severity: major
Location: src/arcp/_runtime/_handler_list_jobs.py:75-84
What
created_after_dt is parsed with dt.datetime.fromisoformat(body.filter.created_after) (lines 33-34) which yields a naive datetime when the client supplies a timestamp without a timezone, while job.submitted_at is timezone-aware UTC. The comparison job.submitted_at <= created_after_dt then raises TypeError: can't compare offset-naive and offset-aware datetimes. The handler only guards the parse (ValueError), not the comparison, so a naive created_after is surfaced to the client as INTERNAL_ERROR instead of a handled result or INVALID_REQUEST.
Evidence
def _matches_filter(
job: Job, body: SessionListJobsPayload, created_after_dt: dt.datetime | None
) -> bool:
if body.filter is None:
return True
if body.filter.status and job.state not in body.filter.status:
return False
if body.filter.agent and job.agent_ref != body.filter.agent:
return False
return not (created_after_dt is not None and job.submitted_at <= created_after_dt)
Proposed fix
Normalize created_after_dt to UTC-aware after parsing (assume UTC when tzinfo is None, e.g. reuse _ensure_utc_iso8601), or reject non-UTC input with INVALID_REQUEST before comparison.
Acceptance criteria
Category: bug Severity: major
Location:
src/arcp/_runtime/_handler_list_jobs.py:75-84What
created_after_dtis parsed withdt.datetime.fromisoformat(body.filter.created_after)(lines 33-34) which yields a naive datetime when the client supplies a timestamp without a timezone, whilejob.submitted_atis timezone-aware UTC. The comparisonjob.submitted_at <= created_after_dtthen raisesTypeError: can't compare offset-naive and offset-aware datetimes. The handler only guards the parse (ValueError), not the comparison, so a naivecreated_afteris surfaced to the client asINTERNAL_ERRORinstead of a handled result orINVALID_REQUEST.Evidence
Proposed fix
Normalize
created_after_dtto UTC-aware after parsing (assume UTC whentzinfo is None, e.g. reuse_ensure_utc_iso8601), or reject non-UTC input withINVALID_REQUESTbefore comparison.Acceptance criteria
session.list_jobswith a tz-naivecreated_afterreturns a normal filtered result (orINVALID_REQUEST), neverINTERNAL_ERROR; covered by a test.