A class that raises on __qualname__ escapes the request type check as its own exception

Open Beginner friendly
#44 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
django, python
Domain
api, backend

Research direction

Read the Codec.send implementation (called Codec.write on main) and its docstring, then locate the request type check and related tests. Add a test using a metaclass whose __getattribute__ raises for __qualname__; make sure the resulting error is a TypeError that keeps the cause. The payload does not name a test file, so find the existing codec tests.

Written by the indexing model from the issue text.

Description

What happens. Codec.send (on main, Codec.write) promises a TypeError for a value that is not exactly the declared record. The message is built with type(value).__qualname__ outside any guard, so a value whose metaclass raises on __qualname__ surfaces as that exception, for example RuntimeError, at Pydantic 2.12.0 and 2.14.3.

Expected. A TypeError that keeps the cause, as the docstring says.

Impact. Minor: it fails closed, nothing is written or sent, and the class has to be built on purpose. Found while reviewing #43; main at 14309e7 behaves the same.

Fix. Build the wrong-type message with guarded name access, or turn any exception raised while building it into the TypeError. Test with a metaclass whose __getattribute__ raises for __qualname__.

Dominant language
Python
Stars
1
Forks
0
Avg merge
5h 30m
Merged PRs (30d)
85

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from stack314/django-neolith

All issues in stack314/django-neolith

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.