Skip to content

Input::isRelative(): Fix assertion failure#474

Merged
edolstra merged 2 commits into
mainfrom
fix-isRelative-crash
May 26, 2026
Merged

Input::isRelative(): Fix assertion failure#474
edolstra merged 2 commits into
mainfrom
fix-isRelative-crash

Conversation

@edolstra
Copy link
Copy Markdown
Collaborator

@edolstra edolstra commented May 26, 2026

Motivation

This happens if a lockfile contains an input with an unknown type field.

Spotted in a Sentry crash report.

SIGABRT / SI_TKILL / 0x0: Fatal Error: SIGABRT / SI_TKILL / 0x0
  libc.so.6           0x7dd077c9caac __pthread_kill_implementation (pthread_kill.c:44)
  libc.so.6           0x7dd077c4190d __GI_raise (raise.c:26)
  libc.so.6           0x7dd077c28941 __GI_abort (abort.c:79)
  libstdc++.so.6      0x7dd0780adc3d null
  libnixfetchers.so.2.34.60x7dd07856ebf3 __wrap___assert_fail (wrap-assert-fail.cc:16)
  libnixfetchers.so.2.34.60x7dd07852c4db nix::fetchers::Input::isRelative[abi:cxx11] (fetchers.cc:177)
  libnixfetchers.so.2.34.60x7dd07852c4db nix::fetchers::Input::isRelative[abi:cxx11] (fetchers.cc:175)
  libnixflake.so.2.34.60x7dd078f1be19 nix::flake::LockedNode::LockedNode (lockfile.cc:78)
  libnixflake.so.2.34.60x7dd078f1e41c std::_Construct<T> (stl_construct.h:119)
  libnixflake.so.2.34.60x7dd078f1e41c std::allocator_traits<T>::construct<T> (alloc_traits.h:706)
  libnixflake.so.2.34.60x7dd078f1e41c std::_Sp_counted_ptr_inplace<T>::_Sp_counted_ptr_inplace<T> (shared_ptr_base.h:607)
  libnixflake.so.2.34.60x7dd078f1e41c std::__shared_count<T>::__shared_count<T> (shared_ptr_base.h:969)
  libnixflake.so.2.34.60x7dd078f1e41c std::__shared_ptr<T>::__shared_ptr<T> (shared_ptr_base.h:1713)
  libnixflake.so.2.34.60x7dd078f1e41c std::shared_ptr<T>::shared_ptr<T> (shared_ptr.h:463)
  libnixflake.so.2.34.60x7dd078f1e41c std::make_shared<T> (shared_ptr.h:1008)
  libnixflake.so.2.34.60x7dd078f1e41c nix::make_ref<T> (ref.hh:164)
  libnixflake.so.2.34.60x7dd078f1e41c _ZZN3nix5flake8LockFileC4ERKNS_8fetchers8SettingsESt17basic_string_viewIcSt11char_traitsIcEES9_ENHUlRKT_RNS0_4NodeERKN8nlohmann16json_abi_v3_12_010basic_jsonISt3mapSt6vectorNSt7__cxx1112basic_stringIcS8_SaIcEEEblmdSaNSG_14adl_serializerESJ_IhSaIhEEvEEE_... (lockfile.cc:171)
  libnixflake.so.2.34.60x7dd078f1f983 nix::flake::LockFile::LockFile (lockfile.cc:182)
  libnixflake.so.2.34.60x7dd078ef7775 nix::flake::readLockFile (flake.cc:428)
  libnixflake.so.2.34.60x7dd078f001c6 nix::flake::lockFlake (flake.cc:449)
  libnixflake.so.2.34.60x7dd078f0350c nix::flake::lockFlake (flake.cc:956)
  nix                 0x5fabcc9dd358 nix::FlakeCommand::lockFlake (flake.cc:61)
  nix                 0x5fabcc9ddd99 .LTHUNK42.lto_priv.0 (flake.cc:176)
  libnixcmd.so.2.34.6 0x7dd07897c2fe nix::StoreCommand::run (command.cc:110)
  libnixcmd.so.2.34.6 0x7dd07897c457 {virtual override thunk}
  nix                 0x5fabcca145f5 nix::mainWrapped (main.cc:638)
  libnixutil.so.2.34.60x7dd079041635 std::function<T>::operator() (std_function.h:591)
  libnixutil.so.2.34.60x7dd079041635 nix::fun<T>::operator()<T> (fun.hh:78)
  libnixutil.so.2.34.60x7dd079041635 nix::handleExceptions (error.cc:489)
  nix                 0x5fabcc974d22 main (main.cc:661)
  libc.so.6           0x7dd077c2a4d7 __libc_start_call_main (libc_start_call_main.h:58)
  libc.so.6           0x7dd077c2a59a __libc_start_main_alias_2 (libc-start.c:360)
  nix                 0x5fabcc97a1f4 _start

Context

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved error handling for inputs without schemes, providing clearer error messages instead of unexpected failures
    • Enhanced robustness when processing unsupported input types, ensuring more graceful degradation

Review Change Stack

This happens if a lockfile contains an input with an unknown `type`
field.
@edolstra edolstra enabled auto-merge May 26, 2026 17:02
cole-h
cole-h previously approved these changes May 26, 2026
@edolstra edolstra force-pushed the fix-isRelative-crash branch from 1b2bd3e to bbbac4d Compare May 26, 2026 17:08
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2c0ded6f-b712-4ba8-bef2-0adf684241f8

📥 Commits

Reviewing files that changed from the base of the PR and between b93743b and bbbac4d.

📒 Files selected for processing (1)
  • src/libfetchers/fetchers.cc

📝 Walkthrough

Walkthrough

Input methods that depend on a scheme now gracefully handle null schemes. Input::isRelative() returns std::nullopt for unsupported input types, while Input::clone() and Input::putFile() throw Error with clear messages, and Input::getSourcePath() returns std::nullopt instead of asserting.

Changes

Null scheme error handling

Layer / File(s) Summary
Optional scheme handling in Input::isRelative()
src/libfetchers/fetchers.cc
isRelative() returns std::nullopt when the input has no scheme, instead of asserting.
Error handling in clone, getSourcePath, and putFile
src/libfetchers/fetchers.cc
clone() and putFile() throw Error with descriptive messages for unsupported inputs; getSourcePath() returns std::nullopt instead of asserting on null scheme.

🎯 2 (Simple) | ⏱️ ~8 minutes

🐰 A scheme once asserted with might,
Now handles null with gentle grace,
Optional returns and errors bright,
Put unsupported inputs in their place!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: fixing an assertion failure in Input::isRelative(), which aligns with the PR objectives of preventing crashes from assertion failures when encountering inputs with unknown types.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-isRelative-crash

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot temporarily deployed to pull request May 26, 2026 17:13 Inactive
@edolstra edolstra added this pull request to the merge queue May 26, 2026
Merged via the queue into main with commit 35cd98d May 26, 2026
29 checks passed
@edolstra edolstra deleted the fix-isRelative-crash branch May 26, 2026 17:52
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