Skip to content

fix(ui,scanner,subsonic): Allow nullable replaygain and support 0.0 #4239

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

Merged
merged 2 commits into from
Jun 17, 2025

Conversation

kgarner7
Copy link
Contributor

Resolves #4236.

Makes the replaygain columns (track/album gain/peak) nullable. Converts the type to a pointer, allowing for 0.0 (a valid value) to be returned from Subsonic. Updates tests for this behavior.

Resolves navidrome#4236.

Makes the replaygain columns (track/album gain/peak) nullable.
Converts the type to a pointer, allowing for 0.0 (a valid value) to be returned from Subsonic.
Updates tests for this behavior.
Copy link
Contributor

@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.

Summary of Changes

Hello @kgarner7, 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 a long-standing issue where replaygain values of 0.0 were not correctly distinguished from missing values. By introducing nullable fields for replaygain in the data model and database, and updating the entire processing pipeline from metadata extraction to API responses, the system can now accurately represent and communicate explicit zero replaygain values, improving data integrity and client compatibility.

Highlights

  • Data Model Update: The RGAlbumGain, RGAlbumPeak, RGTrackGain, and RGTrackPeak fields in the MediaFile model (and related structs like dbMediaFile and ReplayGain in Subsonic responses) have been changed from float64 to *float64. This allows these replaygain values to be nil (representing missing data) or 0.0 (representing an explicit zero value), resolving an issue where 0.0 was indistinguishable from missing data.
  • Database Migration: A new database migration (20250701010104_make_replaygain_fields_nullable.go) has been added to alter the media_file table, making the rg_album_gain, rg_album_peak, rg_track_gain, and rg_track_peak columns nullable. Existing data is preserved during this migration.
  • Metadata Extraction Logic: The metadata extraction logic (model/metadata/map_mediafile.go and model/metadata/metadata.go) has been updated to correctly parse and map replaygain values from tags to the new *float64 fields. This includes a new FloatPointer helper and modifications to mapGain to return nil for invalid or missing values, and a pointer to float64 for valid ones, including 0.0.
  • Subsonic API Compatibility: The Subsonic API response serialization (server/subsonic/responses/responses.go) has been adjusted. The ReplayGain element will now be omitted from XML/JSON responses only if all its fields are nil. If any replaygain value is explicitly 0.0, it will be included in the response, ensuring correct behavior for clients that expect 0.0 as a valid value.
  • Test Coverage: Extensive updates have been made to end-to-end tests, metadata tests, persistence tests, and Subsonic API tests to validate the new nullable and 0.0 handling for replaygain fields across the application stack.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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
Contributor

@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 modifies the system to handle nullable ReplayGain values. The most significant point for improvement is the implementation of the down migration to ensure schema rollback capability.

Signed-off-by: Deluan <deluan@navidrome.org>
@deluan deluan merged commit 7640c47 into navidrome:master Jun 17, 2025
16 checks passed
@kgarner7 kgarner7 deleted the fix-zero-replaygain branch June 18, 2025 02:41
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.

[Bug]: replayGain not returned when it's 0.0
2 participants