Fix log server path extraction to use removeprefix#66749
Merged
Conversation
The log server uses request.url.path.lstrip("/log/") to extract the
requested filename from the URL path. str.lstrip() strips any
combination of the argument characters (here {/, l, o, g}) from the
left of the string -- it does not remove the literal prefix "/log/".
This is a documented Python pitfall.
Switch to str.removeprefix("/log/") (Python 3.9+, already required by
Airflow) so the filename extracted for JWT validation matches the one
the underlying Starlette StaticFiles mount uses to locate the file on
disk.
Generated-by: Claude Opus 4.7 (1M context) following the guidelines at
https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
shahar1
approved these changes
May 12, 2026
vatsrahul1001
approved these changes
May 12, 2026
Contributor
Backport successfully created: v3-2-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
github-actions Bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
May 12, 2026
…e#66749) The log server uses request.url.path.lstrip("/log/") to extract the requested filename from the URL path. str.lstrip() strips any combination of the argument characters (here {/, l, o, g}) from the left of the string -- it does not remove the literal prefix "/log/". This is a documented Python pitfall. Switch to str.removeprefix("/log/") (Python 3.9+, already required by Airflow) so the filename extracted for JWT validation matches the one the underlying Starlette StaticFiles mount uses to locate the file on disk. (cherry picked from commit d8865dd) Co-authored-by: Jarek Potiuk <jarek@potiuk.com> Generated-by: Claude Opus 4.7 (1M context) following the guidelines at https: //github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
aws-airflow-bot
pushed a commit
to aws-mwaa/upstream-to-airflow
that referenced
this pull request
May 12, 2026
…e#66749) The log server uses request.url.path.lstrip("/log/") to extract the requested filename from the URL path. str.lstrip() strips any combination of the argument characters (here {/, l, o, g}) from the left of the string -- it does not remove the literal prefix "/log/". This is a documented Python pitfall. Switch to str.removeprefix("/log/") (Python 3.9+, already required by Airflow) so the filename extracted for JWT validation matches the one the underlying Starlette StaticFiles mount uses to locate the file on disk. (cherry picked from commit d8865dd) Co-authored-by: Jarek Potiuk <jarek@potiuk.com> Generated-by: Claude Opus 4.7 (1M context) following the guidelines at https: //github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions
vatsrahul1001
pushed a commit
that referenced
this pull request
May 15, 2026
… (#66772) The log server uses request.url.path.lstrip("/log/") to extract the requested filename from the URL path. str.lstrip() strips any combination of the argument characters (here {/, l, o, g}) from the left of the string -- it does not remove the literal prefix "/log/". This is a documented Python pitfall. Switch to str.removeprefix("/log/") (Python 3.9+, already required by Airflow) so the filename extracted for JWT validation matches the one the underlying Starlette StaticFiles mount uses to locate the file on disk. (cherry picked from commit d8865dd) Generated-by: Claude Opus 4.7 (1M context) following the guidelines at https: //github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
May 20, 2026
… (#66772) The log server uses request.url.path.lstrip("/log/") to extract the requested filename from the URL path. str.lstrip() strips any combination of the argument characters (here {/, l, o, g}) from the left of the string -- it does not remove the literal prefix "/log/". This is a documented Python pitfall. Switch to str.removeprefix("/log/") (Python 3.9+, already required by Airflow) so the filename extracted for JWT validation matches the one the underlying Starlette StaticFiles mount uses to locate the file on disk. (cherry picked from commit d8865dd) Generated-by: Claude Opus 4.7 (1M context) following the guidelines at https: //github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
May 20, 2026
… (#66772) The log server uses request.url.path.lstrip("/log/") to extract the requested filename from the URL path. str.lstrip() strips any combination of the argument characters (here {/, l, o, g}) from the left of the string -- it does not remove the literal prefix "/log/". This is a documented Python pitfall. Switch to str.removeprefix("/log/") (Python 3.9+, already required by Airflow) so the filename extracted for JWT validation matches the one the underlying Starlette StaticFiles mount uses to locate the file on disk. (cherry picked from commit d8865dd) Generated-by: Claude Opus 4.7 (1M context) following the guidelines at https: //github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
vatsrahul1001
pushed a commit
that referenced
this pull request
May 21, 2026
… (#66772) The log server uses request.url.path.lstrip("/log/") to extract the requested filename from the URL path. str.lstrip() strips any combination of the argument characters (here {/, l, o, g}) from the left of the string -- it does not remove the literal prefix "/log/". This is a documented Python pitfall. Switch to str.removeprefix("/log/") (Python 3.9+, already required by Airflow) so the filename extracted for JWT validation matches the one the underlying Starlette StaticFiles mount uses to locate the file on disk. (cherry picked from commit d8865dd) Generated-by: Claude Opus 4.7 (1M context) following the guidelines at https: //github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions Co-authored-by: Jarek Potiuk <jarek@potiuk.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The log server uses
request.url.path.lstrip("/log/")to extract the requested filename from the URL path.str.lstrip()strips any combination of the argument characters (here{/, l, o, g}) from the left of the string — it does not remove the literal prefix"/log/". This is a documented Python pitfall (see https://docs.python.org/3/library/stdtypes.html#str.lstrip).This PR switches to
str.removeprefix("/log/")(Python 3.9+, already required by Airflow) so the filename extracted for JWT validation matches the one the underlying StarletteStaticFilesmount uses to locate the file on disk.Test plan
test_forbidden_lstrip_character_overlapinairflow-core/tests/unit/utils/test_serve_logs.pyexercises the{/, l, o, g}character-set overlap.test_serve_logs.pytests continue to pass.Tracker: airflow-s/airflow-s#401.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Opus 4.7 (1M context) following the guidelines at https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions