Skip to content

feat(mapper): map Flask blueprint prefixes#100

Open
rohitjavvadi wants to merge 2 commits into
openclaw:mainfrom
rohitjavvadi:feat/flask-blueprint-prefixes
Open

feat(mapper): map Flask blueprint prefixes#100
rohitjavvadi wants to merge 2 commits into
openclaw:mainfrom
rohitjavvadi:feat/flask-blueprint-prefixes

Conversation

@rohitjavvadi
Copy link
Copy Markdown
Contributor

Summary

Flask route discovery handled route decorators on blueprints, but it did not apply static url_prefix values from either Blueprint(..., url_prefix=...) or app.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.ts
  • git diff --check
  • ./node_modules/.bin/tsc -p tsconfig.build.json

@rohitjavvadi rohitjavvadi requested a review from a team as a code owner May 20, 2026 19:06
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/mappers/python.ts Outdated
Comment on lines +1369 to +1371
const prefix = parsePythonKeywordStringArg(args, "url_prefix");
if (prefix !== null) {
prefixes.set(target, prefix);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant