Skip to content

Commit

Permalink
Don't log "403" from worker serve-logs as "Unknown error". (#37933)
Browse files Browse the repository at this point in the history
If you make a request to `http://localhost:8793/` it would get denied
from this block on L82:

```python
            auth = request.headers.get("Authorization")
            if auth is None:
                logger.warning("The Authorization header is missing: %s.", request.headers)
                abort(403)
``

abort is internally implemented to raise an exception. However since
that `abort()` call was inside a try/except block, it was getting caught
under the `execpt Exception:` fallback and running this:

```
        except Exception:
            logger.warning("Unknown error", exc_info=True)
            abort(403)
```

So nothing was wrong with the behaviour (it still 403d the request),
it's just the logs were slightly confusing.
  • Loading branch information
ashb authored Mar 7, 2024
1 parent 8eeb93a commit 7cebff8
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions airflow/utils/serve_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
InvalidSignatureError,
)
from setproctitle import setproctitle
from werkzeug.exceptions import HTTPException

from airflow.configuration import conf
from airflow.utils.docs import get_docs_url
Expand Down Expand Up @@ -96,6 +97,8 @@ def validate_pre_signed_url():
token_filename,
)
abort(403)
except HTTPException:
raise
except InvalidAudienceError:
logger.warning("Invalid audience for the request", exc_info=True)
abort(403)
Expand Down

0 comments on commit 7cebff8

Please sign in to comment.