Skip to content

Conversation

@jnovinger
Copy link
Member

@jnovinger jnovinger commented Mar 25, 2025

Fixes: #18991

GenericArrayForeignKey, which was added in #18826, advertised itself as a many_to_many relation, which is seemingly somewhat inaccurate and triggered DRF's introspection of many_to_many relations which looks for a remote_field.model property chain on the relation. Since that doesn't exist, DRF threw an AttributeError resulting in a 500 error.

This changes GenericArrayForeignKey to advertise itself to DRF as a one_to_many relation, which is more accurate, and does not trigger the property access in DRF that was causing the problem.

This also adds a regression test for both FrontPort and RearPort "path" API views.

`GenericArrayForeignKey`, which was added in #18826, advertised itself
as a many_to_many relation, which is somewhat inaccurate and triggered
DRF's introspection of many_to_many relations which looks for a
`remote_field.model` property chain on the relation. Since that doesn't
exist, DRF threw an AttributeError resulting in a 500 error.

This changes `GenericArrayForeignKey` to advertise itself to DRF as a
one_to_many relation, which is more accurate, and does not trigger the
property access in DRF that was causing the problem.

This also adds a regression test for both FrontPort and RearPort "path"
API view.
@jnovinger jnovinger requested review from a team and arthanson and removed request for a team March 25, 2025 18:53
@arthanson arthanson merged commit fd2bcda into main Mar 26, 2025
6 checks passed
@jnovinger jnovinger deleted the 18991-front-rear-port-paths-broken-api branch March 26, 2025 17:13
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Path tracing broken for front/rear ports in REST API

3 participants