Skip to content

Invalid URL when paginating TestRail API endpoints (double '?' in index.php path) #175

@paudmir

Description

@paudmir

Details

  • Python version: Python 3.12.3
  • pytest-testrail version (pip show pytest-testrail): Name: pytest-testrail Version: 3.1.1
  • TestRail version (if known): TestRail v10.1.3 Early Access (1006)
  • Minimal code example to reproduce:

Just added --tr-skip-missing to my pytest command.

  • Full error traceback
17:07:50 DEBUG https://oxidecomputer.testrail.io:443 "GET /index.php?/api/v2/get_run/15 HTTP/1.1" 200 727
17:07:51 DEBUG https://oxidecomputer.testrail.io:443 "GET /index.php?/api/v2/get_tests/15 HTTP/1.1" 200 3996
17:07:51 DEBUG https://oxidecomputer.testrail.io:443 "GET /index.php?/api/v2/get_tests/15?limit=250&offset=0 HTTP/1.1" 400 71
17:07:51 ERROR Failed to get tests: Invalid characters in URI: [/api/v2/get_tests/15?limit]
collected 59 items

Then Claude helped me check, and looks like this is the fix:

● Update(oxide/product-assurance/pytest_tests/venv/lib/python3.12/site-packages/pytest_testrail/testrail_api.py)
⎿  Added 1 line, removed 1 line

      302              ...     print(test['id'])
      303          """
      304          offset = 0
      305 -        separator = "&" if "?" in uri else "?"
      305 +        separator = "&"  # _api_url already contains '?' (index.php?/api/v2/)
      306
      307          while True:
      308              paginated_uri = f"{uri}{separator}limit={limit}&offset={offset}"

● That's it. The index.php?/api/v2/ base URL already has a ? baked in, so pagination params always need &. The plugin's check "?" in
uri was looking at just get_tests/15 instead of the full URL, so it always picked ? — wrong answer every time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions