Skip to content

Fix Django STAC search query parameter handling - #2412

Merged
tomkralidis merged 2 commits into
geopython:masterfrom
Shubham-Padkonde:fix/django-stac-query-params
Sep 22, 2026
Merged

tomkralidis merged 2 commits into
geopython:masterfrom
Shubham-Padkonde:fix/django-stac-query-params

Conversation

@Shubham-Padkonde

@Shubham-Padkonde Shubham-Padkonde commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Overview

Fixes #2411.

Django's QueryDict stores lists internally, so dict(request.params) turns scalar query values into lists. This breaks STAC GET pagination (for example limit=10) and POST searches that retain query parameters.

Copy the mapping's items() instead, preserving each framework's scalar lookup semantics. Apply this to both POST overrides and pagination, using the public params property. The regression cases use a real Django QueryDict through APIRequest.from_django and cover repeated limit parameters, POST limit precedence, bbox retention, previous/next links, and preservation of the original query mapping.

Related issue / discussion

#2411. No dependency or public API changes.

Validation

Windows, Python 3.13:

  • Both new cases fail against unchanged upstream e7ecbe0 and pass with this change.
  • Initial regression run: python -m pytest tests/api/test_stac.py -q: 8 passed. After moving the Django regressions as requested, python -m pytest tests/api/test_stac.py tests/other/test_django.py -q: 10 passed, with dependency warnings; changed-file flake8 and whitespace checks pass.
  • python -m flake8: passed across the repository.
  • Broader run of tests/api/test_stac.py tests/api/test_api.py tests/api/test_itemtypes.py: 42 passed, 6 failed. All six existing failures reproduce on unchanged upstream: test_apirules_active, test_apirules_inactive, test_api_exception, test_describe_collections, test_describe_collections_enclosures, and test_get_collection_item. With the two new regression cases included, upstream has 40 passed and 8 failed.
  • The full external-service suite and a deployed Django server were not run. Existing Starlette deprecation warnings remain.

Additional information

Prepared and tested with OpenAI Codex assistance.

Additional information

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

No dependencies are added, removed, or changed. Django remains in the existing Django requirements, and the regression now resides in the Django-specific test module.

Updates to public demo

No public API, configuration, or deployment changes are introduced; there is no breaking demo change to address. The public demo was not redeployed as part of this fix.

Contributions and licensing

(as per https://github.com/geopython/pygeoapi/blob/master/CONTRIBUTING.md#contributions-and-licensing)

  • I'd like to contribute the Django STAC query-parameter bug fix (GET STAC /search with parameters fails with Django #2411) to pygeoapi. I confirm that my contributions to pygeoapi will be compatible with the pygeoapi license guidelines at the time of contribution
  • I have already previously agreed to the pygeoapi Contributions and Licensing Guidelines

@tomkralidis tomkralidis added this to the 0.25.0 milestone Sep 21, 2026
Comment thread tests/api/test_stac.py
@Shubham-Padkonde

Copy link
Copy Markdown
Contributor Author

Moved the parametrized Django STAC regression to tests/other/test_django.py as requested, with a dedicated STAC API fixture so the existing Django tests keep their configuration. Removed the Django-specific imports from tests/api/test_stac.py.

Validation: both complete test modules pass (10 tests), plus flake8 and git diff --check. The run reports dependency deprecation/NumPy binary-size/PROJ warnings; no test failures. The API implementation is unchanged in this update.

Prepared with Codex assistance.

@tomkralidis

Copy link
Copy Markdown
Member

Moved the parametrized Django STAC regression to tests/other/test_django.py as requested, with a dedicated STAC API fixture so the existing Django tests keep their configuration. Removed the Django-specific imports from tests/api/test_stac.py.

Validation: both complete test modules pass (10 tests), plus flake8 and git diff --check. The run reports dependency deprecation/NumPy binary-size/PROJ warnings; no test failures. The API implementation is unchanged in this update.

Prepared with Codex assistance.

I've added back in the (removed) text that is included as part of the PR template. Please complete/check off the items on Dependency Policy (RFC2), Updates to public demo, and Contributions and licensing. Thanks.

@Shubham-Padkonde

Copy link
Copy Markdown
Contributor Author

The requested checklist is now completed in the PR description. No dependencies are changed and no demo configuration update is needed. I have personally completed the contributions and licensing checkboxes.

@tomkralidis tomkralidis added the STAC SpatioTemporal Asset Catalog label Sep 22, 2026
@tomkralidis
tomkralidis merged commit 0b38380 into geopython:master Sep 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

STAC SpatioTemporal Asset Catalog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GET STAC /search with parameters fails with Django

3 participants