From 4036f8bbef1ecff0a76b329d69ec125ef77b14a3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 18 Jun 2026 12:13:52 +0000 Subject: [PATCH 1/3] build(deps): bump https://github.com/igorshubovych/markdownlint-cli Bumps [https://github.com/igorshubovych/markdownlint-cli](https://github.com/igorshubovych/markdownlint-cli) from v0.48.0 to 0.49.0. - [Release notes](https://github.com/igorshubovych/markdownlint-cli/releases) - [Commits](https://github.com/igorshubovych/markdownlint-cli/compare/v0.48.0...v0.49.0) --- updated-dependencies: - dependency-name: https://github.com/igorshubovych/markdownlint-cli dependency-version: 0.49.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c7d8a1e..1d1b89a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -113,7 +113,7 @@ repos: # --- Markdown --- - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.48.0 + rev: v0.49.0 hooks: - id: markdownlint name: "📝 markdownlint - Lint markdown files" From bfef6c4b1acd4361269591fe629531b48717aa36 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Jun 2026 12:13:56 +0000 Subject: [PATCH 2/3] build(deps): bump actions/checkout from 6 to 7 Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/1.bump-version.yml | 2 +- .github/workflows/2.build-publish.yml | 4 ++-- .github/workflows/3.update-changelog.yml | 2 +- .github/workflows/publish-docs.yml | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/1.bump-version.yml b/.github/workflows/1.bump-version.yml index fc16d78..f7de4c7 100644 --- a/.github/workflows/1.bump-version.yml +++ b/.github/workflows/1.bump-version.yml @@ -17,7 +17,7 @@ jobs: contents: write steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Bump version env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/2.build-publish.yml b/.github/workflows/2.build-publish.yml index ad214ee..a3d3269 100644 --- a/.github/workflows/2.build-publish.yml +++ b/.github/workflows/2.build-publish.yml @@ -17,7 +17,7 @@ jobs: # contents: read # steps: # - name: Checkout - # uses: actions/checkout@v6 + # uses: actions/checkout@v7 # - name: Set up Python # uses: actions/setup-python@v6 # with: @@ -37,7 +37,7 @@ jobs: contents: write steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Get latest version run: | git pull origin main diff --git a/.github/workflows/3.update-changelog.yml b/.github/workflows/3.update-changelog.yml index 29d9902..c04eefa 100644 --- a/.github/workflows/3.update-changelog.yml +++ b/.github/workflows/3.update-changelog.yml @@ -14,7 +14,7 @@ jobs: contents: write steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 - name: Update changelog env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index aee75cf..46dacb5 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -17,7 +17,7 @@ jobs: contents: write steps: - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v7 with: fetch-depth: 0 - name: Set up Python From ac9340855c80ca67bea815505f40ee4e9f65d369 Mon Sep 17 00:00:00 2001 From: Batkhuu Byambajav Date: Sat, 4 Jul 2026 17:50:46 +0900 Subject: [PATCH 3/3] fix: update beans-logging version and improve request handling in middlewares --- requirements.txt | 2 +- src/beans_logging_fastapi/middlewares.py | 24 +++++++++++++----------- src/modules/beans_logging | 2 +- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/requirements.txt b/requirements.txt index 940861d..969139e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ fastapi>=0.99.1,<1.0.0 -beans-logging>=12.0.3,<13.0.0 +beans-logging>=12.0.4,<13.0.0 diff --git a/src/beans_logging_fastapi/middlewares.py b/src/beans_logging_fastapi/middlewares.py index b97ec88..be09628 100644 --- a/src/beans_logging_fastapi/middlewares.py +++ b/src/beans_logging_fastapi/middlewares.py @@ -44,8 +44,9 @@ async def dispatch(self, request: Request, call_next: Callable) -> Response: _http_info["request_id"] = request.headers.get("X-Correlation-ID") # Set request_id to request state: - request.state.request_id = _http_info["request_id"] + request.state.request_id = _http_info.get("request_id") + _http_info["client_host"] = "0.0.0.0" # nosec: B104 if request.client: _http_info["client_host"] = request.client.host @@ -59,7 +60,7 @@ async def dispatch(self, request: Request, call_next: Callable) -> Response: ) _http_info["request_port"] = request.url.port - _http_info["http_version"] = request.scope["http_version"] + _http_info["http_version"] = request.scope.get("http_version", "1.1") if self.has_proxy_headers: if "X-Real-IP" in request.headers: @@ -159,11 +160,11 @@ async def dispatch(self, request: Request, call_next: Callable) -> Response: if hasattr(request.state, "user_id"): _http_info["user_id"] = str(request.state.user_id) - _logger = logger.bind(request_id=_http_info["request_id"]) + _logger = logger.bind(request_id=_http_info.get("request_id")) # Set http info to request state: request.state.logger = _logger - request.state.client_ip = _http_info.get("client_host", "") + request.state.client_host = _http_info.get("client_host") request.state.http_info = _http_info response: Response = await call_next(request) return response @@ -204,10 +205,10 @@ async def dispatch(self, request: Request, call_next: Callable) -> Response: "should be parseable to !" ) else: - response.headers["X-Process-Time"] = str(_http_info["response_time"]) + response.headers["X-Process-Time"] = str(_http_info.get("response_time", 0)) if "X-Request-ID" not in response.headers: - response.headers["X-Request-ID"] = _http_info["request_id"] + response.headers["X-Request-ID"] = _http_info.get("request_id", "") if hasattr(request.state, "user_id"): _http_info["user_id"] = str(request.state.user_id) @@ -330,19 +331,20 @@ async def dispatch(self, request: Request, call_next) -> Response: # Http access log: _LEVEL = "INFO" _sub_format = self.sub_format - if _http_info["status_code"] < 200: + _status_code = _http_info.get("status_code", 200) + if _status_code < 200: _LEVEL = "DEBUG" _sub_format = f'{_sub_format.replace("{status_code}", "{status_code}")}' - elif (200 <= _http_info["status_code"]) and (_http_info["status_code"] < 300): + elif (200 <= _status_code) and (_status_code < 300): _LEVEL = "SUCCESS" _sub_format = f'{_sub_format.replace("{status_code}", "{status_code}")}' - elif (300 <= _http_info["status_code"]) and (_http_info["status_code"] < 400): + elif (300 <= _status_code) and (_status_code < 400): _LEVEL = "INFO" _sub_format = f'{_sub_format.replace("{status_code}", "{status_code}")}' - elif (400 <= _http_info["status_code"]) and (_http_info["status_code"] < 500): + elif (400 <= _status_code) and (_status_code < 500): _LEVEL = "WARNING" _sub_format = _sub_format.replace("{status_code}", "{status_code}") - elif 500 <= _http_info["status_code"]: + elif 500 <= _status_code: _LEVEL = "ERROR" _sub_format = ( f'{_sub_format.replace("{status_code}", "{status_code}")}' diff --git a/src/modules/beans_logging b/src/modules/beans_logging index f73865e..51ea229 160000 --- a/src/modules/beans_logging +++ b/src/modules/beans_logging @@ -1 +1 @@ -Subproject commit f73865e343befb3458b40f2f5d3c093cf5ffb459 +Subproject commit 51ea2294c31451f1cc1a55f198cc2a1812942da2