Skip to content

POST /testsets/revisions/{id}/upload silently fails when testset_id is not set on the commit #4176

@mmabrouk

Description

@mmabrouk

Summary

POST /api/testsets/revisions/{testset_revision_id}/upload (CSV and JSON) returns {"count": 0} and does not actually create a new revision or testcases. Repros on eu.cloud.agenta.ai.

Root cause (code-level)

In api/oss/src/apis/fastapi/testsets/router.py the upload handler create_testset_revision_from_file builds a TestsetRevisionCommit with only testset_revision_id and data:

testset_revision_commit = TestsetRevisionCommit(
    testset_revision_id=testset_revision_id,
    data=testset_revision_data,
)

commit_testset_revision in api/oss/src/core/testsets/service.py then assigns testcase.set_id = testset_revision_commit.testset_id (which is None) for every testcase being created, and passes the payload to testsets_dao.commit_revision. The upstream git DAO / blobs DAO requires artifact_id (the testset_id) to scope writes, so the commit no-ops and the endpoint returns {"count": 0}.

Repro (against eu.cloud.agenta.ai)

  1. Create a simple testset via POST /api/simple/testsets/ — get testset_id and revision_id (HEAD).
  2. POST /api/testsets/revisions/{revision_id}/upload with a CSV or JSON file (legacy __dedup_id__ or canonical testcase_dedup_id).
  3. Response: {"count": 0}.
  4. POST /api/testsets/revisions/log confirms no new revision was created.

POST /api/simple/testsets/{testset_id}/upload and POST /api/simple/testsets/upload (new testset) both work — they go through different code paths that set the testset_id correctly.

Expected

The upload should create a new revision with the uploaded testcases (same behavior as /simple/testsets/{id}/upload), and return the new revision payload with count: 1.

Suggested fix

In the upload handler, resolve the revision's testset_id from the testset_revision_id (or pass testset_id on the TestsetRevisionCommit) before calling commit_testset_revision. The delta commit path already does this resolution in _commit_testset_revision_delta.

Scope

Docs PR-5 (testsets) is not papering over this — the concept page and endpoint docstrings note that the structured upload endpoint currently does not commit correctly and will be fixed separately. Bug is filed so the fix isn't tied to the docs cycle.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BackendbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions