Skip to content

Fix incorrect hl[] line highlights in oauth2-scopes docs - #15854

Closed
krunal12345 wants to merge 1 commit into
fastapi:masterfrom
krunal12345:fix/oauth2-scopes-hl-lines
Closed

Fix incorrect hl[] line highlights in oauth2-scopes docs#15854
krunal12345 wants to merge 1 commit into
fastapi:masterfrom
krunal12345:fix/oauth2-scopes-hl-lines

Conversation

@krunal12345

Copy link
Copy Markdown

Summary

Several code example sections in docs/en/docs/advanced/security/oauth2-scopes.md had wrong line numbers in their hl[] highlight directives, causing incorrect lines (including blank lines and completely unrelated code) to be highlighted instead of the relevant code.

All line numbers were verified against the exact content of docs_src/security/tutorial005_an_py310.py.

Bugs fixed

Section Before After Issue
Global view hl[5,9,13,47,65,106,108:116,122:126,130:136,141,157] hl[5,9,13,47,65:68,108:119,122:126,130:136,143:145,159:163] Multiple wrong lines (see below)
OAuth2 Security scheme hl[63:66] hl[65:68] Line 63 = DUMMY_HASH = ... (unrelated); missed scopes= dict on line 67
JWT token with scopes hl[157] hl[159:163] Line 157 =
aise HTTPException for bad password (unrelated); should highlight create_access_token with scope data
Declare scopes in path operations hl[5,141,172] hl[5,143:145,173:176] Lines 141 and 172 are blank lines
Use SecurityScopes hl[9,106] hl[9,108] Line 106 is a blank line
Use the scopes hl[106,108:116] hl[108:119] Line 106 is blank; range cut off mid-exception block
Verify username and data shape hl[47,117:129] hl[47,120:132] Lines 117-119 are the end of the previous section's HTTPException
Verify the scopes hl[130:136] hl[133:140] Lines 130-132 = user lookup (not scope verification); range cut off mid-exception

Checklist

  • Verified all line numbers against docs_src/security/tutorial005_an_py310.py
  • Only hl[] directives changed — no prose or code modified

Several code example sections referenced wrong line numbers, causing
the wrong code lines to be highlighted:

- "OAuth2 Security scheme": hl[63:66] started on DUMMY_HASH line and
  missed the scopes= dict on line 67; fixed to hl[65:68]
- "JWT token with scopes": hl[157] highlighted the wrong HTTPException
  (bad password error); fixed to hl[159:163] (create_access_token
  with scope data)
- "Use SecurityScopes": hl[106] was a blank line; fixed to hl[108]
- "Use the scopes": hl[106,...] was blank line + incomplete exception
  block; fixed to hl[108:119]
- "Declare scopes in path operations": hl[141] and hl[172] were blank
  lines; fixed to hl[143:145,173:176]
- "Verify username and data shape": hl[117:129] started mid-exception
  block; fixed to hl[120:132]
- "Verify the scopes": hl[130:136] included unrelated user-lookup
  lines and cut off mid-exception; fixed to hl[133:140]
- Global view: updated to reflect all the above corrections
@github-actions github-actions Bot added the docs Documentation about how to use FastAPI label Jun 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@YuriiMotov

YuriiMotov commented Jun 29, 2026

Copy link
Copy Markdown
Member

@krunal12345, thanks for your interest.
Could you please explain how you verified the changes? Did you carefully review it by yourself of just asked AI to review?

I just opened the diff between tutorial004_an_py310.py and tutorial005_an_py310.py, and compared it with the highlights. And they don't match:

image

I suggest we close this PR and report this in #15849
This PR doesn't really help maintainers as reviewing it would take approximately the same time (or even more if it contains mistakes) than fixing this from scratch.

Thank you for understanding!

@YuriiMotov YuriiMotov closed this Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation about how to use FastAPI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants