3

I am trying to fetch bundles from the Tangle based on their tail transaction hashes. I am trying to follow step 7 of the Pyota Tutorial

I successfully encrypted data and included it in a zero-value transaction as described in step 6. The transaction is visible in the Tangle Explorer and a nice green Confirmed tag is associated with it.

Unfortunately when I run the script and insert the Tail transaction hash of the bundle I get the following error:

Looking for bundle on the Tangle...
Traceback (most recent call last):
  File "read_encrypted_transaction.py", line 21, in <module>
    bundle = api.get_bundles([tail_hash])['bundles'][0]
  File "/home/userk/development/git/autodichiarazione_2.0/consistency_check/environ/lib/python3.6/site-packages/iota/api.py", line 721, in get_bundles
    return extended.GetBundlesCommand(self.adapter)(transaction=transaction)
  File "/home/userk/development/git/autodichiarazione_2.0/consistency_check/environ/lib/python3.6/site-packages/iota/commands/__init__.py", line 126, in __call__
    replacement = self._prepare_request(self.request)
  File "/home/userk/development/git/autodichiarazione_2.0/consistency_check/environ/lib/python3.6/site-packages/iota/commands/__init__.py", line 300, in _prepare_request
    failure_message = 'Request failed validation',
  File "/home/userk/development/git/autodichiarazione_2.0/consistency_check/environ/lib/python3.6/site-packages/iota/commands/__init__.py", line 335, in _apply_filter
    'filter_errors': runner.get_errors(with_context=True),
ValueError: Request failed validation ({'transaction': ['wrong_type']}) (`exc.context["filter_errors"]` contains more information).

What am I missing?

EDIT Here is the complete exception info:

Looking for bundle on the Tangle...
{'filter_errors': {'transaction': [{'code': 'wrong_type',
                                    'context': {'code': 'wrong_type',
                                                'filter': 'Type(TryteString, '
                                                          'bytearray, bytes, '
                                                          'str, '
                                                          'allow_subclass=True)',
                                                'key': 'transaction',
                                                'replacement': None,
                                                'value': ['QEZGSZYP9FXJZJIZQJILXGMIMMFQXGFGP9NOGDJJV9PAWJRYLTACOICVKOPYUVVCTNPFDJUTQPAJMI999']},
                                    'exc_info': None,
                                    'message': 'list is not valid (allowed '
                                               'types: TryteString, bytearray, '
                                               'bytes, str).'}]}}

Additional Infos

pip show pyota
Name: PyOTA
Version: 2.1.0
Summary: IOTA API library for Python
Home-page: https://github.com/iotaledger/iota.py
Author: Phoenix Zerin
Author-email: phx@phx.ph
License: MIT
Location: /home/userk/development/git/autodichiarazione_2.0/consistency_check/environ/lib/python3.6/site-packages
Requires: pysha3, requests, six, phx-filters
4

Thanks for including the additional info in your question!

I was about to write the answer to update to the newest PyOTA version, but you were faster with your comment.

So yes, PyOTA 2.3.0b1 should solve the issue! :)

| improve this answer | |
  • Glad to accept your first answer as the solution – UserK Mar 24 at 21:17
3

Welcome to the IOTA StackExchange! I'm sorry (and a tad embarrassed 😅) to hear that you encountered an error during the tutorials! Hopefully we can get you back on track quickly!

The error message indicates two things:

Request failed validation ({'transaction': ['wrong_type']})

PyOTA attempted to craft a request to fetch information about the bundle, but somewhere (internally, it seems), there was a transaction parameter that had the wrong type.

This may indicate a bug in PyOTA, but we'll need a bit more context in order to get to the bottom of it, which brings me to:

(exc.context["filter_errors"] contains more information).

Virtually every exception that PyOTA raises has a context object attached to it with more information that may be relevant to the error. Could you modify your code a bit and edit your question to include the output it produces?

from pprint import pprint
try:
    bundle = api.get_bundles([tail_hash])['bundles'][0]
except Exception as e:
   pprint(getattr(e, 'context', {}) 
   raise

I suspect this will need to be posted on PyOTA's issue tracker, but it would be good to gather more information first.

| improve this answer | |
  • 1
    Thanks for the warm welcome. I might be using an old version of the library. I have updated my question with the requested information – UserK Mar 24 at 20:01
  • 1
    Solved using a newer version of the library 2.3.0b1. Mea culpa. Works like a charm. You guys have done a wonderful job. Should I accept your answer or write myself one with the solution? – UserK Mar 24 at 20:58
  • Sorry todofixthis – UserK Mar 24 at 21:17
  • Sweet as! I'm glad to hear that you were able to resolve the issue! Feel free to post your own solution as an answer and accept it — that way other visitors will have two different tools to approach this issue if they encounter it in the future 😺 – todofixthis Mar 24 at 22:47
  • Oh, nevermind; Levente figured it out first 😹 – todofixthis Mar 24 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.