Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trp2.get_block_by_id #176

Open
Shayndee opened this issue Apr 7, 2024 · 2 comments
Open

trp2.get_block_by_id #176

Shayndee opened this issue Apr 7, 2024 · 2 comments
Labels
enhancement New feature or request python Relates to the Python version of TRP

Comments

@Shayndee
Copy link

Shayndee commented Apr 7, 2024

if there is no block returned from self.find_block_by_id, it raises ValueError no block for id and then fails to parse the rest of the page.

@athewsey athewsey added the python Relates to the Python version of TRP label Apr 8, 2024
@athewsey
Copy link
Contributor

athewsey commented Apr 8, 2024

I'm not deep on the Python version of the library, but from what I understand this may be by design... What's your expected behaviour for missing blocks referenced in the response, @Shayndee?

e.g.

  1. Raise a validation error at load/parse time?
  2. Gracefully ignore missing blocks at load/parse time, but raise an error when attempting to access them later?
  3. Gracefully ignore missing blocks altogether, wherever they're referenced?

@athewsey
Copy link
Contributor

athewsey commented Jun 7, 2024

Following up on this after diving a bit deeper:

TDocument provides two alternative methods depending on your desired error handling behaviour:

From your original description, I understand the issue is that TRP throwing an error when trying to initially load/parse a JSON that references (i.e. somewhere in a block's Relationships) a block ID that does not exist?

I understand (unless @Belval wants to correct me) that this behaviour of throwing an error on loading a document with missing block(s) is by design and ability to nicely handle malformed JSON would be a feature request.

  1. If I'm right, could you help by sharing some extra details on what type of block is missing from your JSON / where it's referenced?
  2. If I'm wrong and you're seeing an actual bug with find_block_by_id itself throwing an error, please let us know!

@athewsey athewsey added the enhancement New feature or request label Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request python Relates to the Python version of TRP
Projects
None yet
Development

No branches or pull requests

2 participants