Skip to content

return 400 for filters the SQL provider cannot apply - #2483

Open
colivetree wants to merge 1 commit into
geopython:masterfrom
colivetree:fix-sql-filter-400
Open

colivetree wants to merge 1 commit into
geopython:masterfrom
colivetree:fix-sql-filter-400

Conversation

@colivetree

Copy link
Copy Markdown

Overview

A filter the SQL provider can't apply now returns a 400 instead of an uncaught exception and an HTML 500:

  • a value the column type can't hold (osm_id=x), on PostgreSQL
  • an operator the column type doesn't support (osm_id LIKE 'a%'), on PostgreSQL
  • a quoted column name ('name' LIKE 'a%'), on PostgreSQL and MySQL

Most of the sql.py diff is re-indentation from the new try. git diff -w shows the 30 or so lines that really changed.

Related Issue / discussion

Closes #2480

Additional information

Faults the request didn't cause stay errors: a DataError with no filter, a misconfigured time_field, and any ProgrammingError other than 42883.

Testing:

  • 41 new test cases, including 30 I ran against the unfixed code and saw fail. Existing tests are unchanged and still pass.
  • Each line of the fix was mutated in turn, and the tests caught all 9 mutants.
  • Full CI on my fork: 712 passed, 0 failed (main (3.12)), plus flake8.
  • Over HTTP with gunicorn and the test config: osm_id=x and the CQL cases went from an HTML 500 to a JSON 400.

An AI assistant (Claude Code) helped me investigate this and prepare the patch. I'm directing the work and will follow it through.

Dependency policy (RFC2)

  • I have ensured that this PR meets RFC2 requirements

No new dependencies.

Updates to public demo

No configuration changes.

Contributions and licensing

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

  • I'd like to contribute a bugfix 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

🤖 Generated with Claude Code

https://claude.ai/code/session_01UA1Vh8atCEhdk3WycqYunj

A filter value the column type cannot hold, or a CQL filter that compares a
quoted column name, raised an uncaught exception and returned an HTML 500.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UA1Vh8atCEhdk3WycqYunj
@github-actions github-actions Bot added the AI generated Label for the detect-ai workflow classifier label Nov 11, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI generated Label for the detect-ai workflow classifier

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SQL providers return HTML 500 for filters the database cannot apply

1 participant