-
Couldn't load subscription status.
- Fork 48
Fix reportLink nil handling to prevent crashes when report functionality unavailable #30
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
|
@graycreate 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
Co-authored-by: graycreate <5203798+graycreate@users.noreply.github.com>
Code Coverage Report ❌Current coverage: 0% |
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.
Pull Request Overview
This PR fixes a crash issue where reportLink could be nil but was being force unwrapped when users attempted to report topics that don't have report functionality available.
Key changes:
- Prevents nil
reportLinkby initializing it as empty string when no report URL is found - Adds safety guards in report action to handle empty report links gracefully
- Updates UI to disable report button when reporting is unavailable
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| V2er/State/DataFlow/Model/FeedDetailInfo.swift | Ensures reportLink is initialized as empty string instead of remaining nil |
| V2er/State/DataFlow/Actions/FeedDetailActions.swift | Adds guard to safely check report link before proceeding with report action |
| V2er/View/FeedDetail/FeedDetailPage.swift | Adds logic to disable report button when report link is unavailable |
| V2erTests/V2erTests.swift | Adds test case to verify proper handling of empty report links |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| override func setUpWithError() throws { | ||
| // Put setup code here. This method is called before the invocation of each test method in the class. | ||
| 13.5} | ||
| } |
Copilot
AI
Sep 20, 2025
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.
The removed line contains invalid syntax 13.5} which would cause compilation errors. This appears to be a formatting issue in the diff rather than intentional code.
Code Coverage Report ❌Current coverage: 0% |
This PR addresses a crash issue where
reportLinkcould be nil but was being force unwrapped, causing the app to crash when users attempted to report topics that don't have report functionality available.Problem
The issue occurred in the feed detail parsing logic where:
rawReportUrl), thereportLinkproperty remained nilFeedDetailActions.swiftwould force unwrapstate.model.reportLink!, causing a crashSolution
Model Layer (
FeedDetailInfo.swift):elseclause to initializereportLinkas an empty string whenrawReportUrlis emptyreportLinkis never nil, preventing force unwrap crashesAction Layer (
FeedDetailActions.swift):reportLinkexists and is not empty before proceedingUI Layer (
FeedDetailPage.swift):canReportlogic to disable the report button whenreportLinkis emptyTesting
Added a test case to verify that
reportLinkis properly initialized as an empty string rather than remaining nil.This fix ensures the app handles V2EX topics that don't support reporting functionality without crashing, while maintaining full functionality for topics that do support reporting.
Fixes #4.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.