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

TypeError: %d format: a number is required, not NoneType #35

Open
sentry-io bot opened this issue Mar 8, 2021 · 3 comments
Open

TypeError: %d format: a number is required, not NoneType #35

sentry-io bot opened this issue Mar 8, 2021 · 3 comments

Comments

@sentry-io
Copy link

sentry-io bot commented Mar 8, 2021

We use Sentry to get stacktraces and variable values on CourtListener. This is coming from a live user on CourtListener:

TypeError: %d format: a number is required, not NoneType
(5 additional frame(s) were not displayed)
...
  File "cl/search/views.py", line 449, in show_results
    render_dict.update(do_search(request.GET.copy()))
  File "cl/search/views.py", line 193, in do_search
    query_citation = get_query_citation(cd)
  File "cl/lib/search_utils.py", line 124, in get_query_citation
    matches = match_citation(citations[0])
  File "cl/citations/match_citations.py", line 140, in match_citation
    main_params["fq"].append('citation:("%s")' % citation.base_citation())
  File "eyecite/models.py", line 62, in base_citation
    return "%d %s %s" % (self.volume, self.reporter, self.page)

I'm on vacation this week (last one for a bit, promise), so I won't look at this too much, but it seems to be because the user queried using a Supra that got parsed incorrectly such that the Volume was None.

The query that triggered it is:

https://www.courtlistener.com/?q=Williamson%20v.%20Tucker%2C%20supra%2C%20645%20F.2d%20

Sentry Issue: COURTLISTENER-17K

@mattdahl, any chance you want to take a look and have a minute? Inside CL, this is coming from a feature that looks for citations inside people's queries, so it can give them an info box. You can see an example of it working normally here:

https://www.courtlistener.com/?q=558%20U.S.%20310

And I'm filing in eyecite, but I don't actually know if this is CL or eyecite. Of course we could work around it in CL, but maybe it's worth pushing upstream.

@mattdahl
Copy link
Contributor

mattdahl commented Mar 9, 2021

To some extent, this should already be fixed. In the version of eyecite that is deployed on CL base_citation() is defined as return "%d %s %s" % (self.volume, self.reporter, self.page). This has been changed to "%s %s %s" % (self.volume, self.reporter, self.page) in the version that's on master: https://github.com/freelawproject/eyecite/blob/master/eyecite/models.py#L106

Thus, when self.volume is None, that should simply get coereced to a string without any error. Of course, that's a weird string, but match_citation() in CL can't find out-of-context supra citations like that in any format, so who cares.

However, maybe it would be more principled on the eyecite side to override base_citation in the SupraCitation/IdCitation models. Not sure what the "base" would be conceptually in those contexts, maybe just None?

@mlissner
Copy link
Member

mlissner commented Mar 9, 2021

Yeah, feels like just returning None would make sense.

A little fix in CL to ignore supra citations in queries might be good too?

@mattdahl
Copy link
Contributor

Okay, I misread our inheritance scheme, IdCitationand SupraCitation don't even have base_citation() methods anymore. So there is nothing to fix in that respect in eyecite.

On the CL side, I agree that that would be a good change, but it will be simpler to do once the new version of eyecite is merged. Then we can just check for CaseCitation objections. I'll try to remember to fix that once I finish the new integration.

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

No branches or pull requests

2 participants