Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
answer_prompt_bp = Blueprint("answer-prompt", __name__)


@AuthHelper.auth_required
@answer_prompt_bp.route("/answer-prompt", methods=["POST"])
@AuthHelper.auth_required
def prompt_processor() -> Any:
platform_key = AuthHelper.get_token_from_auth_header(request)
payload: dict[Any, Any] = request.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
]


@AuthHelper.auth_required
@extraction_bp.route("/extract", methods=["POST"])
@AuthHelper.auth_required
def extract() -> Any:
Comment on lines 21 to 23
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Missing functools.wraps in auth_required changes Flask endpoint names

Now that @route is applied after @AuthHelper.auth_required, Flask registers the inner wrapper function (returned by auth_required) rather than the original handler. Because auth.py's auth_required does not call @functools.wraps(func) on its wrapper, the three endpoints are now registered under the endpoint name "wrapper" instead of "extract", "index", and "prompt_processor". Each lives in a separate blueprint so there is no immediate collision here, but if a second @auth_required-decorated route is ever added to any of these blueprints the app will crash at startup with a duplicate-endpoint AssertionError. Adding @functools.wraps(func) to the wrapper inside AuthHelper.auth_required in helpers/auth.py fixes this for all three controllers at once.

Prompt To Fix With AI
This is a comment left during a code review.
Path: prompt-service/src/unstract/prompt_service/controllers/extraction.py
Line: 21-23

Comment:
**Missing `functools.wraps` in `auth_required` changes Flask endpoint names**

Now that `@route` is applied after `@AuthHelper.auth_required`, Flask registers the inner `wrapper` function (returned by `auth_required`) rather than the original handler. Because `auth.py`'s `auth_required` does not call `@functools.wraps(func)` on its wrapper, the three endpoints are now registered under the endpoint name `"wrapper"` instead of `"extract"`, `"index"`, and `"prompt_processor"`. Each lives in a separate blueprint so there is no immediate collision here, but if a second `@auth_required`-decorated route is ever added to any of these blueprints the app will crash at startup with a duplicate-endpoint `AssertionError`. Adding `@functools.wraps(func)` to the `wrapper` inside `AuthHelper.auth_required` in `helpers/auth.py` fixes this for all three controllers at once.

How can I resolve this? If you propose a fix, please make it concise.

Fix in Claude Code

platform_key = AuthHelper.get_token_from_auth_header(request)
payload: dict[Any, Any] = request.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
]


@AuthHelper.auth_required
@indexing_bp.route("/index", methods=["POST"])
@AuthHelper.auth_required
def index() -> Any:
"""Endpoint for indexing documents into the vector database.

Expand Down