Skip to content

Fix multiple bugs discovered during Playwright testing#72

Merged
gudarzi merged 5 commits intogudarzi:v3.0from
thromel:fix/bug-fixes-batch-1
Jan 26, 2026
Merged

Fix multiple bugs discovered during Playwright testing#72
gudarzi merged 5 commits intogudarzi:v3.0from
thromel:fix/bug-fixes-batch-1

Conversation

@thromel
Copy link
Contributor

@thromel thromel commented Jan 18, 2026

Summary

This PR fixes 4 bugs discovered during Playwright testing, plus a test project version mismatch.

Bug #4 (Critical): Spotify Search crashes application

  • Root cause: SpotifySearchService.cs called EnsureSuccessStatusCode() without try-catch, causing unhandled exceptions when the API returns non-2xx status
  • Fix: Added try-catch error handling and Error property to SpotifySearchResult
  • UI: Display errors via MudAlert in SpotifySearch.razor

Bug #1: Incorrect file extension inference (.exe for binary data)

  • Root cause: Helpers.cs mapped application/octet-stream to .exe
  • Fix: Changed mapping to .bin - generic binary data should not default to executable extension

Bug #3: "Autostart Paused Downloads" not working reliably

  • Root cause: StartPausedDownloads() only called once during initial load
  • Fix: Call StartPausedDownloads() when downloads finish/fail and when restoring from persisted state

Bug #5: Proxy Server setting persists unexpectedly

  • Root cause: ProxyUrl had hardcoded default http://localhost:8086
  • Fix: Changed default to empty string, added proxy persistence

Test project fix

  • Updated Microsoft.AspNetCore.Identity.EntityFrameworkCore from 8.0.22 to 8.0.23 (version mismatch)
  • Removed duplicate Microsoft.EntityFrameworkCore.InMemory PackageReference

Test plan

  • All unit tests pass
  • Manual Playwright testing:
    • Spotify search shows error message instead of crashing
    • Proxy Server field is empty by default
    • Autostart works when downloads complete
    • Direct link download uses .bin instead of .exe for application/octet-stream

Files changed

  • SaveHere/Services/SpotifySearchService.cs
  • SaveHere/Components/Utility/SpotifySearch.razor
  • SaveHere/Helpers/Helpers.cs
  • SaveHere/Components/Download/DownloadVideoAudio.razor
  • SaveHere.Tests/SaveHere.Tests.csproj

Bug gudarzi#4 (Critical): Spotify Search crash
- Add try-catch error handling in SpotifySearchService.cs
- Add Error property to SpotifySearchResult
- Display errors via MudAlert in SpotifySearch.razor

Bug gudarzi#1: Incorrect file extension (.exe for binary data)
- Change application/octet-stream mapping from .exe to .bin
- Generic binary data should not default to executable extension

Bug gudarzi#3: Autostart Paused Downloads not working reliably
- Call StartPausedDownloads() when downloads finish/fail
- Call StartPausedDownloads() when restoring from persisted state

Bug gudarzi#5: Proxy Server setting persists unexpectedly
- Change ProxyUrl default from "http://localhost:8086" to empty string
- Persist ProxyUrl in PersistItems() and restore in OnInitializedAsync

Test project fix:
- Update Microsoft.AspNetCore.Identity.EntityFrameworkCore 8.0.22 to 8.0.23
- Remove duplicate Microsoft.EntityFrameworkCore.InMemory reference
@gemini-code-assist
Copy link

Summary of Changes

Hello @thromel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses several critical and minor bugs identified during Playwright testing, significantly improving the application's stability, user experience, and data handling. It ensures that the Spotify search feature gracefully handles API errors, corrects file extension inference for generic binary data, enhances the reliability of autostarting paused downloads, and properly manages the persistence of proxy server settings. Additionally, it includes a minor update to test project dependencies for consistency.

Highlights

  • Spotify Search Stability: Implemented robust error handling in SpotifySearchService.cs to prevent application crashes when the Spotify API returns non-2xx status codes. Errors are now caught and displayed gracefully via a MudAlert in the UI.
  • File Extension Inference Correction: Corrected the file extension inference for application/octet-stream from .exe to .bin in Helpers.cs, providing a safer and more generic default for binary data.
  • Autostart Paused Downloads Reliability: Enhanced the 'Autostart Paused Downloads' feature by ensuring StartPausedDownloads() is called not only during initial load but also when downloads finish or fail, and when restoring from persisted state.
  • Proxy Server Setting Persistence: Resolved an issue where the Proxy Server setting persisted unexpectedly by changing its default value to an empty string and implementing proper persistence and restoration logic.
  • Test Project Dependency Update: Updated the Microsoft.AspNetCore.Identity.EntityFrameworkCore package to resolve a version mismatch and removed a duplicate Microsoft.EntityFrameworkCore.InMemory PackageReference in the test project.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively addresses several bugs discovered during testing, including a critical crash in the Spotify search feature. The fixes are well-implemented, particularly the error handling in SpotifySearchService and the security improvement of changing the default extension for binary streams. The changes for autostarting downloads and persisting the proxy URL also correctly solve the described issues. I have one suggestion to further improve the reliability of the autostart feature and enhance code quality.

Comment on lines 373 to 377
if (newStatus == EQueueItemStatus.Finished.ToString() ||
newStatus == EQueueItemStatus.Paused.ToString())
{
await StartPausedDownloads();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using direct enum comparison is more robust and less error-prone than comparing strings, especially if enum member names change in the future. Since item.Status is already parsed into an enum on line 370, it's better to use it for the check.

Additionally, the Cancelled status seems to be missing from this condition. A cancelled download also frees up a concurrency slot, so triggering StartPausedDownloads() in this case would make the autostart feature more reliable and consistent.

      if (item.Status == EQueueItemStatus.Finished ||
          item.Status == EQueueItemStatus.Paused ||
          item.Status == EQueueItemStatus.Cancelled)
      {
        await StartPausedDownloads();
      }

Copy link
Contributor Author

@thromel thromel Jan 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. ✅ Changed to direct enum comparison using item.Status instead of string comparison
  2. ✅ Added EQueueItemStatus.Cancelled to the condition

Updated in commit 5a51a3c.

@thromel
Copy link
Contributor Author

thromel commented Jan 18, 2026

CI Status Clarification

The CI failures are not due to code issues - they're caused by a GitHub Actions permissions limitation with fork PRs.

What Happened

Check Status Details
Build ✅ Pass Code compiles successfully
Code Analysis ✅ Pass No code quality issues
Security Scan ✅ Pass No vulnerabilities detected
Trivy ✅ Pass Container scan passed
Test ❌ Fail Permissions issue (see below)
Status Check ❌ Fail Depends on Test job

Root Cause

The Test job failed at the "Comment coverage on PR" step with:

HttpError: Resource not accessible by integration
status: 403
url: https://api.github.com/repos/gudarzi/SaveHere/issues/72/comments

This is a known GitHub limitation where workflows triggered by pull_request from forks don't have write permissions to post comments. The actual unit tests passed - the coverage report was generated successfully showing:

  • Line coverage: 30.9%
  • All tests executed without failures

Local Verification

All 128 unit tests pass locally:

Passed!  - Failed: 0, Passed: 128, Skipped: 0, Total: 128

Suggested Fix for Workflow

To allow coverage comments on fork PRs, consider using pull_request_target with proper security measures, or make the comment step conditional:

- name: Comment coverage on PR
  if: github.event.pull_request.head.repo.full_name == github.repository
  # ... rest of step

The code changes in this PR are correct and ready for review.

- Use direct enum comparison instead of string comparison (more robust)
- Add Cancelled status to autostart trigger (cancelled downloads also free slots)
SpotifySearch.razor:
- Show error OR results, not both (prevents confusing UX)

SpotifySearchService.cs:
- Add ILogger for proper error logging with stack traces
- Add TaskCanceledException handling (timeout vs cancellation)
- Map HTTP status codes to user-friendly messages (404, 429, 503)
- Log all errors with full context before returning

DownloadVideoAudio.razor:
- Use Enum.TryParse instead of Enum.Parse (prevents crashes on invalid status)
- Add early return pattern to reduce nesting
- Use enum comparison instead of string comparison for status check
…i#22)

Implement ability to download files that require authentication:
- Basic Auth (username/password)
- Bearer Token (OAuth-style)
- Cookie-based authentication
- Custom HTTP headers

Changes:
- Add AuthenticationType enum with 5 auth modes
- Add 6 auth properties to FileDownloadQueueItem model
- Create HttpRequestAuthenticator helper for applying auth
- Update DownloadQueueService to apply auth at 5 HTTP request points
- Add Authentication Settings UI to DownloadFromDirectLink page
- Add 19 unit tests for HttpRequestAuthenticator
- Include EF Core migration for new database columns

Tested with httpbin.org authentication endpoints.
@gudarzi gudarzi merged commit 444f136 into gudarzi:v3.0 Jan 26, 2026
4 of 6 checks passed
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