Opened 2 years ago

Closed 2 years ago

#16048 closed defect (fixed)

Cannot access bandwidth attribute on RouterV3StatusEntry

Reported by: tom Owned by: atagar
Priority: Medium Milestone:
Component: Core Tor/Stem Version:
Severity: Keywords:
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

I was checking to see if I needed to do anythign to update depictor to work with Stem 1.4.0

I saw that .measured[0] went away, and seems to have been replaced by .bandwidth

[0] https://gitweb.torproject.org/depictor.git/tree/website.py#n551

But I get an error on some router, as shown below:

Traceback (most recent call last):
  File "./write_website.py", line 159, in <module>
    main()
  File "./write_website.py", line 71, in main
    w.write_website(os.path.join(os.path.dirname(__file__), 'out', 'consensus-health.html'), True)
  File "/tor/depictor/website.py", line 36, in write_website
    self._write_bandwidth_scanner_status()
  File "/tor/depictor/website.py", line 553, in _write_bandwidth_scanner_status
    if r.bandwidth >= 0L:
  File "/tor/depictor/stem/descriptor/__init__.py", line 603, in __getattr__
    parsing_function(self, self._entries)
  File "/tor/depictor/stem/descriptor/router_status_entry.py", line 253, in _parse_w_line
    descriptor.unrecognized_bandwidth_entries.append(w_entry)
  File "/tor/depictor/stem/descriptor/__init__.py", line 603, in __getattr__
    parsing_function(self, self._entries)
  File "/tor/depictor/stem/descriptor/router_status_entry.py", line 253, in _parse_w_line
    descriptor.unrecognized_bandwidth_entries.append(w_entry)
  File "/tor/depictor/stem/descriptor/__init__.py", line 603, in __getattr__
    parsing_function(self, self._entries)
  File "/tor/depictor/stem/descriptor/router_status_entry.py", line 253, in _parse_w_line
    descriptor.unrecognized_bandwidth_entries.append(w_entry)
  File "/tor/depictor/stem/descriptor/__init__.py", line 603, in __getattr__
    parsing_function(self, self._entries)
  File "/tor/depictor/stem/descriptor/router_status_entry.py", line 253, in _parse_w_line
    descriptor.unrecognized_bandwidth_entries.append(w_entry)
  File "/tor/depictor/stem/descriptor/__init__.py", line 603, in __getattr__
    parsing_function(self, self._entries)
  File "/tor/depictor/stem/descriptor/router_status_entry.py", line 253, in _parse_w_line
    descriptor.unrecognized_bandwidth_entries.append(w_entry)

I added a print r.nickname right before that line, and it died on the relay 'DasielFR1' - but I don't see anything unique or unusual about that one...

Child Tickets

Change History (10)

comment:1 Changed 2 years ago by atagar

Interesting! Would you mind attaching the file it's choking on, or making a dump on https://paste.debian.net/?

The stacktrace is because we expect parsing functions to only raise ValueErrors or KeyErrors. That aside though, I wouldn't expect that particular line to be raising anything so it'll take a little digging once I have a repro.

On a side note, for DepicTor you might want to consider opting into decriptor validation. Stem 1.4.0 changes validation from being opt-out to opt-in for performance reasons, but for your use case the extra validation checks might be more useful than speed. Up to you.

Validation would likely sidestep this particular error but still something we obviously should fix (and probably get a hotfix for the release).

Thanks for the catch!

comment:2 Changed 2 years ago by tom

Using validate = True in the Downloader did indeed solve the problem!

I will work on finding a file that repros it later (have things I need to get done off-PC today), but I think just running depictor without validation would repro it. My normal workflow broke also, or I would do that, I filed #16054 for that.

comment:3 Changed 2 years ago by atagar

Using validate = True in the Downloader did indeed solve the problem!

Purely a workaround. Obviously not a fix. :P

I will work on finding a file that repros it later (have things I need to get done off-PC today)

Yup, ditto. Gonna be at a local festival most of today but this is pretty high on my todo list once I have a repro so we can get a hotfix out (preferably fixing the pickling issue too).

comment:4 Changed 2 years ago by tom

It's GuardFraction :)

Moria is the only authority voting on that now, so trying to access a bandwidth attribute on moria's vote will cause the error.

Moria's vote: http://128.31.0.34:9131/tor/status-vote/current/authority

comment:5 Changed 2 years ago by atagar

Tried having stem read moria1's vote but seems to be happy...

from stem.descriptor import DocumentHandler
from stem.descriptor.remote import DescriptorDownloader, get_authorities

downloader = DescriptorDownloader()
query = downloader.get_vote(get_authorities()['moria1'], document_handler = DocumentHandler.DOCUMENT, validate = True)

print query.run()[0]

Tried this both with and without validation. Are you still able to repro this? If so, mind providing a standalone script that repros the problem?

comment:6 Changed 2 years ago by tom

from stem.descriptor import DocumentHandler
from stem.descriptor.remote import DescriptorDownloader, get_authorities

downloader = DescriptorDownloader()
query = downloader.get_vote(get_authorities()['moria1'], document_handler = DocumentHandler.DOCUMENT, validate = False)

r = query.run()[0]
for i in r.routers:
    print r.routers[i].bandwidth

That should repro it.

comment:7 Changed 2 years ago by atagar

Huh. That doesn't repro an error for me.

comment:8 Changed 2 years ago by atagar

Failure to repro was purely my bad. Fixed the issue, this will be part of the 1.4.1 hotfix release once the git repos are available again.

comment:9 Changed 2 years ago by atagar

Fixed, and made a 1.4.1 hotfix release. Thanks for the catches!

comment:10 Changed 2 years ago by atagar

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.