Skip to content

feat: limit too big filters - #216

Open
LionelZoubritzky-IGN wants to merge 2 commits into
mainfrom
151/reject-big-filters
Open

LionelZoubritzky-IGN wants to merge 2 commits into
mainfrom
151/reject-big-filters

Conversation

@LionelZoubritzky-IGN

@LionelZoubritzky-IGN LionelZoubritzky-IGN commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Description

Reject any query that requires a too-big CQL filter ("too big" is at 2 MiB, checked experimentally).

Related issues (if applicable)

Close #151, close #215.

Motivation

Too big filters lead to timeout or to silently wrong answers (see #215).

Implementation

Check the size of the intersect_feature_filter and reject it if too large with a clear error message. Also guard against too large CQL filters in general (which could result from a too-large where clause as well).

The filter never silently switches to the -CARTO-PE version because the id can change: departement.72 does not mean the same thing in ADMINEXPRESS-COG.LATEST and in ADMINEXPRESS-COG-CARTO-PE.LATEST. However, the error message gives a hint to the LLM that it should use the -CARTO-PE version.

Testing

npm run build && npm run verify: 611+4+35 tests green and "how many buildings in Vendée" correctly returns around 840000.

Checklist

  • The PR is focused and of a reasonable size.
  • The commit history is clean.
  • Relevant documentation has been updated.
  • Relevant tests have been added or updated.

@LionelZoubritzky-IGN
LionelZoubritzky-IGN marked this pull request as ready for review October 13, 2026 09:00
@LionelZoubritzky-IGN LionelZoubritzky-IGN changed the title feat: limit too big filters and map to "COG-PE" variant where possible feat: limit too big filters Oct 13, 2026
@mborne

mborne commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Tested with ignfab/geocontext-test test_count_batiment_vendee.py (claude-haiku-4-5, local server on this branch):

  • The oversized ADMINEXPRESS-COG.LATEST:departement geometry is now rejected as expected (3803688 octets de filtre encodé (limite : 2097152)).
  • But with the original question ("Combien y a-t-il de bâtiments dans le département de la Vendée ?"), the model follows the "ou utiliser un filtre bbox" hint: it fetches the department bbox, counts with bbox_filter and answers 1 111 470 buildings (neighbouring departments included) without any warning.
  • When asking for a precise count (ignfab/geocontext-test@a8d1b8d), the model still tries the bbox first, then switches to ADMINEXPRESS-COG-CARTO-PE.LATEST:departement and answers 854 362 (2/2 runs).

Suggestion: drop the bbox alternative from the error message (or state that it overcounts and must not be used for counting within an administrative unit), and maybe hint how to find the feature in the CARTO-PE layer (e.g. where code_insee = '85') since ids may differ.

🤖 Generated with Claude Code

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

Labels

None yet

Projects

None yet

2 participants