question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could we fail on unknown Attribute?

See original GitHub issue

Could we please add another config option in addition to fail_on_unknown_properties to fail on unknown Attribute?

I don’t currently see that functionality and I’ve experimented by adding random attributes to my parser and they didn’t crash or raise a TypeError.

I am using attrs plugin with the kw_only flag set to true in the config.

I would be expecting similar behaviour to this:

In [1]: import attr

In [2]: @attr.s(frozen=True, slots=True, kw_only=True)
   ...: class Test:
   ...:     a: int = attr.ib()
   ...:     b: str = attr.ib()

In [3]: Test(**{'a': 3, 'b': 'test', 'c': 'tent'})
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-715d11a185fb> in <module>
----> 1 Test(**{'a': 3, 'b': 'test', 'c': 'tent'})

TypeError: __init__() got an unexpected keyword argument 'c'

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tefracommented, Oct 27, 2021

looks great @pashashocky feel free to submit a pull-request

0reactions
pashashockycommented, Nov 1, 2021

@tefra thank you, was a pleasure - and appreciate the tips!

Read more comments on GitHub >

github_iconTop Results From Across the Web

failing on unknown properties w/notification
The DeserializationProblemHandler class seems to do what you want. It allows you to implement this method to handle unknown properties:
Read more >
Unknown attributes should be a warning (not an error)
Can the core team consider making unknown attributes a warning rather than an error? In this case, if, say, @inline(__always) is removed, ...
Read more >
Agile Central: Custom List App - fetchWsapiRecords error
Suddenly, there is an error with "Custom List With Deep Export" app. The error reads: fetchWsapiRecords error: Cannot sort using unknown ...
Read more >
Jackson Unmarshalling JSON with Unknown Properties
In this tutorial, we're going to take a look at the unmarshalling process with Jackson 2.x, specifically how to deal with JSON content...
Read more >
How to Ignore Unknown Properties While Parsing JSON in ...
Another way to deal with unknown properties in JSON you are parsing is to configure ObjectMapper not to fail when it encounters an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found