Skip to content

Modernize 'errors' Django app#18

Draft
Hyask wants to merge 9 commits intomainfrom
skia/modernize_errors
Draft

Modernize 'errors' Django app#18
Hyask wants to merge 9 commits intomainfrom
skia/modernize_errors

Conversation

@Hyask
Copy link
Copy Markdown
Collaborator

@Hyask Hyask commented Apr 2, 2026

Modernizes the errors Django application by cleaning up Python 2 legacy code, updating deprecated Django APIs, and fixing all API endpoints to work correctly under Python 3.

Changes Made

Django modernization (errors)

  • Renamed MIDDLEWARE_CLASSESMIDDLEWARE (Django 1.10+)
  • Simplified wsgi.py to standard get_wsgi_application(), removing oops-wsgi wrappers
  • Removed deprecated SESSION_SERIALIZER = PickleSerializer, ADMIN_MEDIA_PREFIX, and unused ADMINS/MANAGERS settings
  • Added WSGI_APPLICATION setting
  • Replaced django.utils.http.urlquote with urllib.parse.quote
  • Use config.allow_bug_filing instead of settings.ALLOW_BUG_FILING

API endpoint fixes (errors/api/resources.py, errors/cassie.py)

  • All 14 API resource classes used a Python 2 wrapped(list) pattern with __getslice__, which is never called in Python 3 — every endpoint was silently returning empty results. Each resource is now converted to a direct obj_get_list() implementation returning a proper list.
  • Fixed sha1(str)sha1(str.encode()) in CreateBugResource and PackageVersionNewBuckets
  • Removed unnecessary isinstance/encode/decode dance for bucket strings in PackageVersionNewBuckets
  • Removed isinstance(column, str) byte-encoding guard in cassie.get_bucket_counts()
  • Removed unused measure_view import and dead commented-out code in ErrorsResource

JavaScript / template fixes

  • Added null guards for vals and reports_state_fixed_master in JS files
  • Removed server-rendered means variable from main.html (the JS fetches it from the API)

Other fixes

  • launchpad.py: fixed indentation bug in pocket_for_binaries, removed Ubuntu RTM 14.09 workaround
  • src/retracer/config/Ubuntu 26.04/sources.list: added [trusted=yes] to ddebs entries
  • README.md / copilot-instructions.md: documented populate-test-data.sh

[ci skip]
@Hyask Hyask force-pushed the skia/modernize_errors branch from 0296c61 to 6d9421d Compare April 2, 2026 07:36
@Hyask
Copy link
Copy Markdown
Collaborator Author

Hyask commented Apr 2, 2026

@copilot

  • You will only work on the 'errors' app.
  • First, look at that latest commit, make sense out of it, and split it into a few well described commits. You can keep that highlevel, like putting all the JS changes into only one commit.
  • Then keep going on modernizing the Django app:
    • Make sure every API end-point works and return non-empty data (make sure you populated your local Cassandra with populate-test-data.sh).
    • Don't touch the Javascript, Django templates, or regular views for now. UI will come later.

Copilot AI and others added 8 commits April 2, 2026 08:07
…t_list implementations

All API resources previously used a 'wrapped(list)' subclass with __getslice__ to lazily
fetch data from Cassandra when Tastypie applied pagination. In Python 3, __getslice__ is
never called (replaced by __getitem__ with a slice object), causing all these endpoints to
return empty results.

Fix by implementing the logic directly in obj_get_list for each resource, returning a proper
list. Also fix remaining Python 3 str/bytes issues:
- sha1() in CreateBugResource and PackageVersionNewBuckets now uses .encode()
- PackageVersionNewBuckets no longer converts str buckets to bytes unnecessarily
- Remove unused measure_view import and commented-out dead code in ErrorsResource

Co-authored-by: Hyask <7489759+Hyask@users.noreply.github.com>
Co-authored-by: Hyask <7489759+Hyask@users.noreply.github.com>
…hitecture

Co-authored-by: Hyask <7489759+Hyask@users.noreply.github.com>
Co-authored-by: Hyask <7489759+Hyask@users.noreply.github.com>
… Ubuntu RTM workaround

Co-authored-by: Hyask <7489759+Hyask@users.noreply.github.com>
…ted APIs

- Rename MIDDLEWARE_CLASSES to MIDDLEWARE (Django 1.10+)
- Simplify WSGI to standard Django get_wsgi_application(), removing oops-wsgi wrappers
- Remove deprecated SESSION_SERIALIZER = PickleSerializer
- Remove ADMIN_MEDIA_PREFIX (removed in Django 1.4)
- Remove ADMINS/MANAGERS (unused)
- Add WSGI_APPLICATION setting
- Replace django.utils.http.urlquote with urllib.parse.quote
- Use config.allow_bug_filing instead of settings.ALLOW_BUG_FILING

Co-authored-by: Hyask <7489759+Hyask@users.noreply.github.com>
In Python 2, list slicing (obj[start:end]) called __getslice__(start, end).
In Python 3 this method is never called, so all resources using the wrapped(list)
pattern with __getslice__ returned empty results.

Fix by implementing the logic directly in each obj_get_list(), returning proper
lists that Tastypie's paginator can paginate normally.

Also fix remaining Python 3 str/bytes issues:
- sha1() now uses .encode() everywhere (CreateBugResource, PackageVersionNewBuckets)
- Remove unnecessary isinstance/encode/decode dance in PackageVersionNewBuckets
- Remove isinstance(column, str) byte-encoding guard in cassie.get_bucket_counts()
- Remove unused measure_view import and dead commented-out code in ErrorsResource

Co-authored-by: Hyask <7489759+Hyask@users.noreply.github.com>
…m template

- Guard vals and reports_state_fixed_master accesses against null/undefined
- Remove the server-rendered 'means' variable from main.html (data comes from the API)
- Pass no argument to mean_time_between_failures_graph() since means is fetched via API

Co-authored-by: Hyask <7489759+Hyask@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

@copilot

  • You will only work on the 'errors' app.
  • First, look at that latest commit, make sense out of it, and split it into a few well described commits. You can keep that highlevel, like putti...

Done. Since force-pushing isn't available, I used a revert commit to cleanly undo the WIP (and its earlier follow-up) and then re-applied everything as 6 logical commits on top:

  • 84f89db – revert: undo WIP and its follow-up fix to re-apply as clean commits
  • 3a79470 – docs: add mention of populate-test-data.sh script
  • 04570ea – fix(retracer): add trusted=yes flag to Ubuntu 26.04 ddebs sources
  • c8eb8aa – fix(launchpad): fix indentation bug and remove Ubuntu RTM workaround
  • 8101218 – refactor(errors): modernize Django settings, WSGI, and remove deprecated APIs
  • a24ce0a – fix(errors): replace Python 2 __getslice__ pattern in all API resources — this is the main API fix: every resource was using a wrapped(list) subclass with __getslice__ which is never called in Python 3, so all endpoints returned empty results. All 14 resources are now fixed to implement the logic directly in obj_get_list.
  • f877669 – fix(errors/js): add null guards and remove server-side means data from template

Copilot AI changed the title WIP: Modernize 'errors' Modernize 'errors' Django app Apr 2, 2026
Copilot finished work on behalf of Hyask April 2, 2026 08:19
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

Successfully merging this pull request may close these issues.

2 participants