refactor(api): Stop masking refresh-token service errors as 401#38463
Merged
WH-2099 merged 7 commits intoJul 6, 2026
Merged
Conversation
Assisted-by: Codex:GPT-5.4
Contributor
Pyrefly Type Coverage
|
Assisted-by: Codex:GPT-5.4
Assisted-by: Codex:GPT-5.4
…h-token-broad-401 # Conflicts: # api/controllers/console/auth/login.py
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-07-06 08:19:01.732021381 +0000
+++ /tmp/pyrefly_pr.txt 2026-07-06 08:18:52.472972359 +0000
@@ -1,3 +1,5 @@
+ERROR Argument `str | None` is not assignable to parameter `message` with type `bytearray | bytes | str` in function `controllers.common.fields.SimpleResultMessageResponse.__init__` [bad-argument-type]
+ --> controllers/console/auth/login.py:363:71
ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_alibabacloud_mysql.alibabacloud_mysql_vector.AlibabaCloudMySQLVectorFactory.init_vector` [bad-argument-type]
--> providers/vdb/vdb-alibabacloud-mysql/tests/unit_tests/test_alibabacloud_mysql_factory.py:42:38
ERROR Argument `SimpleNamespace` is not assignable to parameter `dataset` with type `Dataset` in function `dify_vdb_alibabacloud_mysql.alibabacloud_mysql_vector.AlibabaCloudMySQLVectorFactory.init_vector` [bad-argument-type]
|
Assisted-by: Codex:GPT-5.4
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.
AI disclosure: This PR was primarily drafted with Codex using GPT-5.4. I have reviewed and edited the final diff, and I am responsible for the content.
Important
Fixes #<issue number>.Summary
Fixes #38462.
Related to #38457.
This change narrows the error handling in
POST /console/api/refresh-tokenand replaces the remaining string-based validation detection with dedicated exception types.What changed:
401response when the refresh-token cookie is missingRefreshTokenNotFoundErrorRefreshTokenAccountNotFoundErrorAccountService.refresh_token(...)Unauthorizedpath from banned-account loading, in the controller and map them to401ValueErrorinstances and operational failures such as runtime/Redis errors to propagate instead of being rewritten as401401validation failures from unexpected exceptions that must continue to bubble upWhy:
ValueErrorwas narrower, but still encoded auth semantics in exception messagesValidation:
uv run --project api pytest -o addopts='' api/tests/unit_tests/controllers/console/auth/test_token_refresh.pyScreenshots
Checklist
make lint && make type-check(backend) andcd web && pnpm exec vp staged(frontend) to appease the lint godsFrom Codex