Skip to content

libflake: fix assertion crash when malformed URL falls through to path scheme#15253

Merged
xokdvium merged 1 commit into
NixOS:masterfrom
obsidiansystems:fix-url-assertion
Feb 16, 2026
Merged

libflake: fix assertion crash when malformed URL falls through to path scheme#15253
xokdvium merged 1 commit into
NixOS:masterfrom
obsidiansystems:fix-url-assertion

Conversation

@amaanq
Copy link
Copy Markdown
Member

@amaanq amaanq commented Feb 16, 2026

Motivation

When a URL like github:nixos/nixpkgs/nixpkgs.git?ref=<hash> (using ref instead of rev) failed the github input scheme, it fell through to parsePathFlakeRefWithFragment which constructed a path: ParsedURL with an empty authority but a relative path. This violated RFC 3986 section 3.3 (authority present requires path starting with /), causing an assertion failure in renderAuthorityAndPath when PathInputScheme tried to format the URL for an error message.

This commit only sets the authority on absolute paths. Relative paths get std::nullopt for authority, which is the correct representation per the URL spec.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@amaanq amaanq requested a review from edolstra as a code owner February 16, 2026 20:06
…h scheme

When a URL like `github:nixos/nixpkgs/nixpkgs.git?ref=<hash>` (using
`ref` instead of `rev`) failed the github input scheme, it fell
through to `parsePathFlakeRefWithFragment` which constructed a `path:`
`ParsedURL` with an empty authority but a relative path. This violated
RFC 3986 section 3.3 (authority present requires path starting with
`/`), causing an assertion failure in `renderAuthorityAndPath` when
`PathInputScheme` tried to format the URL for an error message.

This commit only sets the authority on absolute paths. Relative paths
get `std::nullopt` for authority, which is the correct representation
per the URL spec.

Fixes NixOS#15196. Fixes NixOS#14830.
@xokdvium xokdvium enabled auto-merge February 16, 2026 20:23
@xokdvium xokdvium disabled auto-merge February 16, 2026 20:24
@xokdvium xokdvium enabled auto-merge February 16, 2026 20:25
@xokdvium xokdvium added this pull request to the merge queue Feb 16, 2026
Merged via the queue into NixOS:master with commit 27782fc Feb 16, 2026
14 checks passed
@amaanq amaanq deleted the fix-url-assertion branch March 25, 2026 05:13
brittonr pushed a commit to brittonr/nix that referenced this pull request Apr 1, 2026
libflake: fix assertion crash when malformed URL falls through to path scheme
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.

Nix craches on typo in url nix crashs with assertion exception when input path uses "git"

2 participants