Skip to content

fix: narinfo should return NAR URL normalized#843

Merged
kalbasit merged 1 commit intomainfrom
02-11-fix_narinfo_should_return_nar_url_normalized
Feb 12, 2026
Merged

fix: narinfo should return NAR URL normalized#843
kalbasit merged 1 commit intomainfrom
02-11-fix_narinfo_should_return_nar_url_normalized

Conversation

@kalbasit
Copy link
Owner

When computing a narinfo, normalize the embedded URL before returning
it.

When computing a narinfo, normalize the embedded URL before returning
it.
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Feb 11, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kalbasit, 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 enhances the server's narinfo handling by ensuring that the NAR URL returned in a narinfo response is always in a normalized format. This prevents issues with fetching NARs when the narinfo URL contains an unexpected prefix, thereby improving the robustness and compatibility of the server's caching mechanism.

Highlights

  • NAR URL Normalization: Implemented logic to normalize the NAR URL embedded within narinfo responses. This ensures that any narinfo hash prefix is removed, making the URL consistent with how NARs are served by the server.
  • Improved Compatibility: This change addresses a potential incompatibility issue where upstream caches might provide narinfo entries with prefixed NAR URLs, which previously could lead to failed NAR fetches from the server.
  • Comprehensive Testing: Added a dedicated test case to server_test.go that simulates an upstream narinfo with a prefixed URL and verifies that the server correctly normalizes it in the response, and that the NAR can subsequently be fetched using the normalized URL.
Changelog
  • pkg/server/server.go
    • Added logic to getNarInfo to create a copy of the narInfo object to avoid race conditions.
    • Implemented parsing and normalization of the narInfo.URL field to remove any narinfo hash prefix.
    • Included error handling for nar.ParseURL during normalization.
  • pkg/server/server_test.go
    • Introduced a new test case returns normalized URL in narinfo response within TestServeHTTP.
    • The new test verifies that a narinfo with a prefixed URL is returned with a normalized URL.
    • The test also confirms that a NAR can be successfully fetched using the normalized URL from the narinfo response.
Activity
  • No specific activity (comments, reviews, or progress updates) has been recorded for this pull request yet.
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.

@dosubot dosubot bot added bug Something isn't working go Pull requests that update go code labels Feb 11, 2026
Copy link
Owner Author

kalbasit commented Feb 11, 2026

@dosubot
Copy link

dosubot bot commented Feb 11, 2026

Related Documentation

Checked 7 published document(s) in 1 knowledge base(s). No updates required.

How did I do? Any feedback?  Join Discord

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 correctly normalizes the NAR URL in narinfo responses to handle cases where upstream caches provide prefixed URLs. The change is implemented safely by creating a copy of the narinfo object to avoid side effects on cached data. The accompanying test is thorough, setting up the specific scenario and verifying not only that the URL is normalized in the response, but also that the normalized URL can be successfully used to fetch the NAR. The changes are solid and improve the robustness of the cache server.

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.41%. Comparing base (6bca857) to head (ef6346c).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #843   +/-   ##
=======================================
  Coverage   85.41%   85.41%           
=======================================
  Files           2        2           
  Lines         480      480           
=======================================
  Hits          410      410           
  Misses         65       65           
  Partials        5        5           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kalbasit kalbasit added the backport release-0.8 Backport PR automatically label Feb 12, 2026
@kalbasit kalbasit merged commit cdbe67d into main Feb 12, 2026
19 checks passed
@kalbasit kalbasit deleted the 02-11-fix_narinfo_should_return_nar_url_normalized branch February 12, 2026 01:49
kalbasit added a commit that referenced this pull request Feb 12, 2026
When computing a narinfo, normalize the embedded URL before returning it.

(cherry picked from commit cdbe67d)
@kalbasit
Copy link
Owner Author

Successfully created backport PR for release-0.8:

kalbasit added a commit that referenced this pull request Feb 12, 2026
Bot-based backport to `release-0.8`, triggered by a label in #843.

When computing a narinfo, normalize the embedded URL before returning
it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport release-0.8 Backport PR automatically bug Something isn't working go Pull requests that update go code size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant