Skip to content

Conversation

kimjh12
Copy link
Contributor

@kimjh12 kimjh12 commented Aug 21, 2025

trying to fix below error, which happens if the handler raises an custom exception with source field inside

            locations: list[SourceLocation] | None = [
>               source.get_location(pos) for pos in positions
                ^^^^^^^^^^^^^^^^^^^
            ]
E           AttributeError: 'str' object has no attribute 'get_location'

.tox/py312/lib/python3.12/site-packages/graphql/error/graphql_error.py:161: AttributeError

@kimjh12 kimjh12 requested a review from Cito as a code owner August 21, 2025 03:48
@Cito
Copy link
Member

Cito commented Aug 27, 2025

Thank you @kimjh12.

Some questions to help me understand this better:

  • Can you see which code created the GraphQLError with source which was a str object? Was it your own code?
  • Would it make sense to set source=Source(source) if isinstance(source, str) else None?
  • Wouldn't it be better to put the test in test_located_error?

@Cito
Copy link
Member

Cito commented Sep 14, 2025

Hi @kimjh12 I am planning to do some maintenance on GraphQL-core next week, so I'd appreciate your feedback to fix this properly.

trying to fix below error, which happens if the handler raises an
custom exception with `source` field inside

```
            locations: list[SourceLocation] | None = [
>               source.get_location(pos) for pos in positions
                ^^^^^^^^^^^^^^^^^^^
            ]
E           AttributeError: 'str' object has no attribute 'get_location'

.tox/py312/lib/python3.12/site-packages/graphql/error/graphql_error.py:161: AttributeError
```
@kimjh12
Copy link
Contributor Author

kimjh12 commented Sep 16, 2025

  • Can you see which code created the GraphQLError with source which was a str object? Was it your own code?

Yes, the issue was with my team's code. I updated the diff, thanks

Copy link

codspeed-hq bot commented Sep 19, 2025

CodSpeed Performance Report

Merging #240 will not alter performance

Comparing kimjh12:main (1f63309) with main (fa8f9b5)

Summary

✅ 14 untouched

@Cito Cito merged commit 17be672 into graphql-python:main Sep 19, 2025
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants