codeant-ai-for-open-source[bot] commented on code in PR #41965:
URL: https://github.com/apache/superset/pull/41965#discussion_r3564778271
##########
tests/unit_tests/security/api_test.py:
##########
@@ -66,6 +66,50 @@ def test_csrf_exempt_blueprints_with_api_key(app: Any,
app_context: None) -> Non
assert "ApiKeyApi" in {blueprint.name for blueprint in
csrf._exempt_blueprints}
+def test_security_api_trailing_slash_handled_consistently(client: Any) -> None:
+ """Regression for #29934: sibling ``/api/v1/security/*`` endpoints handle a
+ misspelled (wrong trailing-slash) URL inconsistently.
+
+ Three routes live under the same ``/api/v1/security/`` prefix but are
+ declared with different slash conventions:
+
+ * ``login`` -> ``@expose("/login")`` (no trailing slash,
FAB)
+ * ``csrf_token`` -> ``@expose("/csrf_token/")`` (trailing slash,
Superset)
+ * ``guest_token`` -> ``@expose("/guest_token/")`` (trailing slash,
Superset)
+
+ Because of that mix, a client that gets the slash "wrong" is treated three
+ different ways by Werkzeug routing:
+
+ * ``POST /api/v1/security/login/`` -> 404 (no redirect for the extra
slash)
+ * ``GET /api/v1/security/csrf_token`` -> 308 redirect to the canonical
URL
+ * ``POST /api/v1/security/guest_token`` -> 308 redirect to the canonical
URL
+
+ A user hitting one misspelled security URL gets a clean redirect while
+ another gets a hard 404, which is exactly the inconsistency reported in the
+ issue. This asserts the *desired* contract โ that a trailing-slash
+ misspelling is handled uniformly across the sibling endpoints โ so it fails
+ (red) on master where the responses diverge, and would pass once the slash
+ conventions are unified. It does not prescribe which uniform behavior is
+ correct (all-redirect or all-404), only that they agree.
+ """
+ # (method, canonical route, misspelled route)
Review Comment:
**Suggestion:** The inline comment is factually incorrect: each tuple only
contains two values (method and misspelled URL), not three values including a
canonical route. This mismatch can mislead future edits and cause unpacking
mistakes when someone relies on the documented tuple shape; update the comment
to match the actual data structure. [comment mismatch]
<details>
<summary><b>Severity Level:</b> Minor ๐งน</summary>
```mdx
โ ๏ธ Misleading comment may confuse future test maintainers.
โ ๏ธ Future edits might incorrectly change tuple structure.
```
</details>
<details>
<summary><b>Steps of Reproduction โ
</b></summary>
```mdx
1. Open tests/unit_tests/security/api_test.py and locate function
test_security_api_trailing_slash_handled_consistently at lines 69-110 in the
new hunk.
2. Observe the inline comment at line 95 documenting the tuple shape as
"(method,
canonical route, misspelled route)".
3. Inspect the misspelled list defined at lines 96-100, where each tuple
only contains two
elements: the HTTP method and the misspelled URL.
4. Confirm the loop at lines 101-104 uses "for method, url in misspelled",
unpacking
exactly two values; this proves the comment is factually incorrect and could
mislead
future edits, even though it does not cause a current runtime failure.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=cd45161b9252441fa65545327086e1db&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=cd45161b9252441fa65545327086e1db&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent ๐ค </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/security/api_test.py
**Line:** 95:95
**Comment:**
*Comment Mismatch: The inline comment is factually incorrect: each
tuple only contains two values (method and misspelled URL), not three values
including a canonical route. This mismatch can mislead future edits and cause
unpacking mistakes when someone relies on the documented tuple shape; update
the comment to match the actual data structure.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41965&comment_hash=c5527356897e49541d0d414e0998bbae4951042173c3efecc92d9ffc95fc7244&reaction=like'>๐</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F41965&comment_hash=c5527356897e49541d0d414e0998bbae4951042173c3efecc92d9ffc95fc7244&reaction=dislike'>๐</a>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]