Skip to content

feat(mapper): map Flask blueprint prefixes#100

Merged
steipete merged 4 commits into
openclaw:mainfrom
rohitjavvadi:feat/flask-blueprint-prefixes
May 22, 2026
Merged

feat(mapper): map Flask blueprint prefixes#100
steipete merged 4 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.

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented May 22, 2026

ClawSweeper status: review started.

I am starting a fresh review of this pull request: feat(mapper): map Flask blueprint prefixes This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@steipete steipete merged commit 0ac81b6 into openclaw:main May 22, 2026
6 checks passed
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: 89638eb0e9

ℹ️ 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
Comment on lines +1353 to +1354
const registerCallPattern = /\.register_blueprint\s*\(/gu;
for (const match of source.matchAll(registerCallPattern)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Ignore commented register_blueprint calls in prefix parsing

The new registration-prefix parser scans raw source with source.matchAll(/\.register_blueprint\s*\(/) and does not exclude comments or string literals, so a commented line like # app.register_blueprint(api_bp, url_prefix='/api') is treated as a real registration. In files with blueprint decorators, this can incorrectly override/clear the blueprint prefix and emit wrong route paths in the feature map even though runtime behavior is unchanged.

Useful? React with 👍 / 👎.

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.

2 participants