[PRD-020] 0.1.1 — MoleculerClientError code → HTTP status mapping - #3
Merged
Merged
Conversation
Close KNOWN-ISSUES #19. Previously every MoleculerClientError funnelled
into BadRequestError(400) regardless of the underlying HTTP semantics, so
auth failures raised inside service actions surfaced as "400 Bad Request"
at the gateway — making scripted clients and middlewares unable to
distinguish missing credentials from malformed payloads.
moleculer_error_to_http now inspects err.code and dispatches to the
matching typed gateway error:
* code=401 → UnauthorizedError (HTTP 401)
* code=403 → ForbiddenError (HTTP 403)
* code=404 → NotFoundError (HTTP 404)
* anything else → BadRequestError (HTTP 400, unchanged fallback)
All four UnauthorizedError / ForbiddenError / NotFoundError classes
already existed in errors.py, so this is a pure dispatch fix with no new
public surface.
Evidence:
* tests/unit/test_errors.py — 3 new regression tests
(test_moleculer_client_error_401_maps_to_unauthorized, _403_maps_to_forbidden,
_404_maps_to_not_found) plus the pre-existing default-to-400 test
stays green so backwards compatibility is preserved
* 380/380 tests pass (+3), coverage held at 94%
Refs: PRD-020, KNOWN-ISSUES.md #19
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Companion release for moleculerpy 0.14.22 (PRD-020 bug closure sprint). Ships the #19 fix committed in 1c95efe (moleculer_error_to_http honours MoleculerClientError.code for 401/403/404 instead of funnelling every client error into HTTP 400). CHANGELOG entry documents the fix + counterfactual evidence (reverting moleculer_error_to_http makes demo_web test_client_error_401/403/404 all fail with status=400). Refs: PRD-020, KNOWN-ISSUES.md #19 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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
Companion release moleculerpy-web 0.1.1 for the PRD-020 bug closure sprint in the moleculerpy core repo (PR MoleculerPy/moleculerpy#46, shipping as v0.14.22).
Closes KNOWN-ISSUES #19: `moleculer_error_to_http` now honours `MoleculerClientError.code` and dispatches to the matching typed gateway error (`UnauthorizedError` for 401, `ForbiddenError` for 403, `NotFoundError` for 404). Previously every `MoleculerClientError` funnelled into `BadRequestError(400)` regardless of its code, masking auth failures behind a misleading "Bad Request".
Commits
Evidence
Test plan
Refs
🤖 Generated with Claude Code