Closed Bug 1229783 Opened 9 years ago Closed 8 years ago

[traceback] Stack trace exceptions: ValueError for/api/v1/<resource>/<string>

Categories

(developer.mozilla.org Graveyard :: BrowserCompat, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mbrandt, Assigned: jwhitlock, Mentored)

References

()

Details

(Whiteboard: [type:bug][bc:infra][bc:milestone=bicycle])

Unexpected strings cause 500 errors within the API for /api/v1/<resource>/<string> 

Steps to reproduce:
0. https://browsercompat.herokuapp.com/api/v1/browsers/foxyeah

Additional examples:
https://browsercompat.herokuapp.com/api/v1/versions/799ooi
https://browsercompat.herokuapp.com/api/v1/features/2gg45
https://browsercompat.herokuapp.com/api/v1/supports/m20
https://browsercompat.herokuapp.com/api/v1/specifications/333v
https://browsercompat.herokuapp.com/api/v1/maturities/f
https://browsercompat.herokuapp.com/api/v1/sections/45h
https://browsercompat.herokuapp.com/api/v1/changesets/n0
https://browsercompat.herokuapp.com/api/v1/users/l33t

Expected:
A 404 error is returned

Actual:
A ValueError is thrown.
https://rpm.newrelic.com/accounts/263620/applications/10664840/filterable_errors#/show/a2bb89-e20b58de-9906-11e5-96d2-c81f66b8ceca/stack_trace?top_facet=transactionUiName&bottom_facet=host&primary_facet=error.class&_k=az8fs9

exceptions:ValueError: invalid literal for int() with base 10: 'foxyeah'
Traceback ​(most recent call last)​:​​File "/​app/​.​heroku/​python/​bin/​gunicorn",​ line 11,​ in <module>​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​app/​wsgiapp.​py",​ line 74,​ in run​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​app/​base.​py",​ line 189,​ in run​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​app/​base.​py",​ line 72,​ in run​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​arbiter.​py",​ line 174,​ in run​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​arbiter.​py",​ line 477,​ in manage_​workers​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​arbiter.​py",​ line 540,​ in spawn_​workers​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​arbiter.​py",​ line 507,​ in spawn_​worker​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​workers/​base.​py",​ line 124,​ in init_​process​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​workers/​sync.​py",​ line 119,​ in run​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​workers/​sync.​py",​ line 66,​ in run_​for_​one​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​workers/​sync.​py",​ line 30,​ in accept​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​workers/​sync.​py",​ line 130,​ in handle​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​gunicorn/​workers/​sync.​py",​ line 176,​ in handle_​request​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​newrelic-​2.​58.​0.​43/​newrelic/​api/​web_​transaction.​py",​ line 717,​ in _​_​iter_​_​​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​newrelic-​2.​58.​0.​43/​newrelic/​api/​web_​transaction.​py",​ line 1093,​ in _​_​call_​_​​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​dj_​static.​py",​ line 83,​ in _​_​call_​_​​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​newrelic-​2.​58.​0.​43/​newrelic/​api/​web_​transaction.​py",​ line 1221,​ in _​nr_​wsgi_​application_​wrapper_​​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​core/​handlers/​wsgi.​py",​ line 189,​ in _​_​call_​_​​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​core/​handlers/​base.​py",​ line 132,​ in get_​response​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​newrelic-​2.​58.​0.​43/​newrelic/​hooks/​framework_​django.​py",​ line 499,​ in wrapper​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​views/​decorators/​csrf.​py",​ line 58,​ in wrapped_​view​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​rest_​framework/​viewsets.​py",​ line 87,​ in view​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​newrelic-​2.​58.​0.​43/​newrelic/​hooks/​component_​djangorestframework.​py",​ line 27,​ in _​nr_​wrapper_​APIView_​dispatch_​​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​rest_​framework/​views.​py",​ line 466,​ in dispatch​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​rest_​framework/​views.​py",​ line 463,​ in dispatch​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​rest_​framework/​mixins.​py",​ line 56,​ in retrieve​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​drf_​cached_​instances/​mixins.​py",​ line 50,​ in get_​object​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​drf_​cached_​instances/​mixins.​py",​ line 65,​ in get_​object_​or_​404​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​drf_​cached_​instances/​models.​py",​ line 143,​ in get​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​drf_​cached_​instances/​cache.​py",​ line 136,​ in get_​instances​File "/​app/​webplatformcompat/​cache.​py",​ line 39,​ in browser_​v​1_​loader​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​query.​py",​ line 325,​ in get​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​query.​py",​ line 679,​ in filter​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​query.​py",​ line 697,​ in _​filter_​or_​exclude​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​sql/​query.​py",​ line 1310,​ in add_​q​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​sql/​query.​py",​ line 1338,​ in _​add_​q​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​sql/​query.​py",​ line 1209,​ in build_​filter​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​sql/​query.​py",​ line 1102,​ in build_​lookup​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​lookups.​py",​ line 101,​ in _​_​init_​_​​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​lookups.​py",​ line 139,​ in get_​prep_​lookup​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​fields/​_​_​init_​_​.​py",​ line 727,​ in get_​prep_​lookup​File "/​app/​.​heroku/​python/​lib/​python​2.​7/​site-​packages/​django/​db/​models/​fields/​_​_​init_​_​.​py",​ line 985,​ in get_​prep_​value​
Related to bug 1078699 - strings need to be accepted URL patterns if a resource is available by slug, but misses need to be 404s, not 500s.
Blocks: 996570
Keywords: in-triage
OS: Unspecified → All
Hardware: Unspecified → All
Summary: [browsercompat][traceback] Stack trace exceptions:ValueError for/api/v1/<resource>/<string> → [traceback] Stack trace exceptions: ValueError for/api/v1/<resource>/<string>
Whiteboard: [browsercompat] → [type:bug][bc:infra]
Blocks: 1240757
No longer blocks: 996570
Mentor: jwhitlock
Adding to "production-ready" milestone
Whiteboard: [type:bug][bc:infra] → [type:bug][bc:infra][bc:milestone=motorbike]
Pulling back to "bicycle" milestone, since it will be fixed with the rest of slug/alias bugs
Whiteboard: [type:bug][bc:infra][bc:milestone=motorbike] → [type:bug][bc:infra][bc:milestone=bicycle]
Assignee: nobody → jwhitlock
Status: NEW → ASSIGNED
Commits pushed to master at https://github.com/mdn/browsercompat

https://github.com/mdn/browsercompat/commit/6ffcb57dd41d596f470c3bc9fdcdff17f954b2ad
bug 1229783 - Full router.get_urls implementation

Instead of calling super, bring in the get_urls() implementation from
rest_framework.routers.  This code is about to get some modifications,
but this commit doesn't change current functionality.

https://github.com/mdn/browsercompat/commit/f14559ff2cce51999445a1b3211f25958f184f69
bug 1229783 - Move viewfeature formats to viewset

https://github.com/mdn/browsercompat/commit/c3a6c7539f7a4d366fa320594ea2aa5ad6685bb8
fix bug 1229783 - Restrict resource IDs to ints

Instead of matching any string, restrict resource IDs to integers in URL
patterns. Let viewsets declare an alternative_lookup function, to be
used if an alternate lookup, like viewfeatures's slug lookup, is
allowed. This means that resource lookups will default to 404's for
non-integer IDs.

https://github.com/mdn/browsercompat/commit/040276972d16c34491921df9aaee9e261eeb298d
Merge pull request #98 from mdn/require_int_ids_1229783

fix bug 1229783 - require integer IDs 

r=self
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Product: developer.mozilla.org → developer.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.