feat(mapper): map Flask blueprint prefixes#100
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 00ea29943e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const prefix = parsePythonKeywordStringArg(args, "url_prefix"); | ||
| if (prefix !== null) { | ||
| prefixes.set(target, prefix); |
There was a problem hiding this comment.
Clear constructor prefix when registration prefix is dynamic
When register_blueprint(..., url_prefix=...) uses a non-literal value (for example API_PREFIX), parsePythonKeywordStringArg returns null, so this block skips updating the map and leaves any constructor-derived prefix in place. In Flask, registration options override blueprint defaults, so a blueprint defined with url_prefix='/api' but registered with a dynamic prefix will be mapped as /api/... here even though the runtime prefix is different/unknown. This produces incorrect route paths in feature maps for common factory setups that override prefixes at registration time.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5625f6d: dynamic register_blueprint url_prefix values now clear constructor prefixes so unknown runtime mounts no longer emit stale static paths. Also covered None/default fallback and inline-comment literal cases with regressions.
Summary
Flask route discovery handled route decorators on blueprints, but it did not apply static
url_prefixvalues from eitherBlueprint(..., url_prefix=...)orapp.register_blueprint(..., url_prefix=...). That made common same-file blueprint routes appear at the wrong path in the feature map.This adds static same-file prefix discovery for Flask blueprints, applies registration prefixes with registration-time precedence, and leaves dynamic prefixes unmodified so the mapper does not guess at runtime values.
Verification
./node_modules/.bin/vitest run src/mapper.test.ts./node_modules/.bin/vitest run./node_modules/.bin/tsc -p tsconfig.json --noEmit./node_modules/.bin/oxlint . --config oxlint.json./node_modules/.bin/oxfmt --check src/mappers/python.ts src/mapper.test.tsgit diff --check./node_modules/.bin/tsc -p tsconfig.build.json