← Back to Pull requests

[16.0][FIX] endpoint_route_handler: drop route_group length limit #205

Open
unknown opened this pull request with 388 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 30, 2026 14:06 UTC
Author

endpoint_route.route_group is created as VARCHAR(32). Any group longer than
32 characters makes the route registration fail after the record was saved:

psycopg2.errors.StringDataRightTruncation: value too long for type character varying(32)
  ...
  File "endpoint_route_handler/registry.py", line 201, in _update
    return query_multi_update(

The most visible case is shopfloor_base: an app registers its routes under
shopfloor.app:<tech_name>, so any shopfloor.app whose technical name is
longer than 18 characters is saved but gets no routes (every endpoint answers
404, and the app only says the login failed). The same happens for an
endpoint.endpoint whose free-text "Route Group" is longer than 32 characters.

The limit seems to have been copied from endpoint_hash on the line above when
the table was introduced in #3. Nothing depends on it: there is no index or
constraint on the column, the lookup is a plain equality filter, and the ORM
field route_group has no size. key and route in the same table have no
limit either.

Changes

  • route_group is created as VARCHAR without a length limit.

  • migrations/16.0.1.1.4/pre-migrate.py drops the limit on existing databases

  • (the table is only created on install). Widening a varchar is a catalog-only
    change in PostgreSQL: no table rewrite.
  • get_rules_by_group built its WHERE clause with an f-string, so a group

  • containing a quote broke the query and the value ended up as SQL. The group
    is now passed as a query parameter; get_rules / _get_rules take an
    optional params tuple for the placeholders of where (default (), so the
    current callers behave as before).

    Tests

  • test_route_group_longer_than_32_chars: rules with a 77-character group are

  • stored and found by group.
  • test_get_rule_by_group_is_escaped: a group containing a quote is found, and

  • x' OR '1'='1 returns nothing.
  • test_migration_drops_route_group_length_limit: the pre-migration turns a

  • VARCHAR(32) column into an unlimited one.

    Also checked on a database with shopfloor_base: an app with a 30-character
    technical name registers all its routes after the migration.

    Not changed here

    Noticed while reviewing, left out to keep this fix small:

  • _setup_db only creates the table and never aligns existing columns with

  • _columns, so any future type change needs its own migration like this one.
  • route_group has no index; get_rules_by_group scans the table.

  • get_rules(keys=[]) returns every rule, since an empty list counts as no

  • filter.

    Forward port

    17.0, 18.0, 19.0 and the open 20.0 migration (#177) have the same column
    definition and the same f-string. In 19.0, OCA/rest-framework#634 gave the
    fastapi.endpoint.route_group field size=32 to match the column; that size
    can be relaxed once this is forward-ported.

    AI assistance

    Prepared with Claude Code (Claude Opus 5.5): tracing the error to the column
    definition, searching the history and the other branches, drafting the fix,
    tests and this description. I reviewed the change and ran the tests myself.

    Diff: 388 lines (+291 / -97) across 4 files Reviewer: simahawk Review duration: 480m
    All Vouch review confidence checks passed
    Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 388 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.357
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #205"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 43.1% (MEDIUM) · Higher = larger blast radius
    43.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 23.0% · Safe to merge
    23.0%
    Repository