-
Notifications
You must be signed in to change notification settings - Fork 54
fix: Address multiple server errors found in production logs #983
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
Conversation
…issing When queue_test() is called but no matching Test record exists in the database, platform_test.id would throw AttributeError: 'NoneType' object has no attribute 'id'. This can happen when: - The pull_request webhook was not received or failed - There's a mismatch in query parameters (commit, platform, test_type, pr_nr) - A race condition between webhook processing The fix adds a null check with a descriptive error log before attempting to access platform_test.id. This prevents the 500 error and provides debugging information. Root cause identified from webhook delivery showing 500 error at 18:26:14 on 2025-12-28 when Windows build completed for PR #1920. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Fix 'CommitStatus' object not subscriptable error in start_ci webhook handler by using attribute access (status.context) instead of dict syntax (status["context"]) for PyGithub CommitStatus objects - Fix FileNotFoundError in progress_reporter by ensuring TempFiles and TestResults directories exist before saving/moving uploaded files - Fix BuildError for login redirects by storing full URL path instead of just endpoint name, preventing crashes when endpoints require URL parameters (e.g., sample_id, test_id) - Add open redirect protection to login handler - Update tests to match new login redirect behavior 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
mod_auth/controllers.py
Outdated
| g.log.warning(f'login protected endpoint {request.endpoint} accessed before logging in') | ||
| return redirect(url_for('auth.login', next=request.endpoint)) | ||
| # Store the full URL path instead of just the endpoint name to preserve URL parameters | ||
| return redirect(url_for('auth.login', next=request.full_path.rstrip('?'))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not mistaken this could lead to security risks, are you sure this is safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed - reverted to using endpoint name and added try/except around url_for() to catch BuildError gracefully. Now redirects to home page when the endpoint requires parameters we don't have.
mod_auth/controllers.py
Outdated
| if redirect_location and (not redirect_location.startswith('/') or redirect_location.startswith('//')): | ||
| redirect_location = '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably does not catch all cases... So I'd rather see the old version and just handle the error more gracefully.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed - reverted to the old approach. Now using try/except around url_for() to catch BuildError and redirect to home page instead. This avoids the security concerns while still preventing the 500 errors.
…path Address maintainer feedback: - Revert to using endpoint name in login_required decorator - Add try/except around url_for() to catch BuildError - Redirect to home page when endpoint requires parameters we don't have - Revert tests to original assertions This is a safer approach than storing the full URL path, which could introduce security risks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update test assertions to account for additional os.path.join and os.makedirs calls added to ensure TempFiles and TestResults directories exist before file operations. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|



Summary
This PR fixes multiple server errors identified from analyzing production logs in
/tmp/sp:Issues Fixed
1.
AttributeError: 'NoneType' object has no attribute 'id'in queue_testmod_ci/controllers.py:1305queue_test()assumed Test record always existsplatform_test.id2.
TypeError: 'CommitStatus' object is not subscriptablemod_ci/controllers.py:1498status["context"]but PyGithub returns objects, not dictsstatus.contextattribute access3.
FileNotFoundErrorin progress_reportermod_ci/controllers.py:2135-2150TempFilesandTestResultsdirectories may not existos.makedirs(..., exist_ok=True)before file operations4.
BuildError: Could not build url for endpoint 'sample.download_sample'mod_auth/controllers.py(login redirect)url_for()in try/except, redirect to home page on BuildErrorFiles Changed
mod_ci/controllers.py- Null check, CommitStatus fix, directory creationmod_auth/controllers.py- Graceful error handling for login redirectsTest plan
🤖 Generated with Claude Code