Fix panic on cabal.project.freeze installed constraints dropping all Haskell packages#5040
Fix panic on cabal.project.freeze installed constraints dropping all Haskell packages#5040Synvoya wants to merge 1 commit into
cabal.project.freeze installed constraints dropping all Haskell packages#5040Conversation
GHC boot-lib constraints (any.base installed) have no ' ==', so fields[1] panicked with index out of range and the recover dropped all Haskell packages. Skip constraint lines without a version. Signed-off-by: Synvoya <16019863+Synvoya@users.noreply.github.com>
|
Heads-up on the red Static analysis check — it isn't from this change. The job failed while pulling a container image from ghcr.io during setup ( |
|
The failing Static analysis check didn't actually reach the linters — the job aborted in the |
Description
syftpanics on realcabal.project.freezefiles and drops all Haskell packages from the scan.Every
cabal freezeemitsany.<pkg> installed,constraints for GHC boot libraries (base,array,ghc-prim, ...).parseCabalFreezesplits each constraint on" =="and unconditionally readsfields[1]; aninstalledline has no" ==", sofieldshas length 1 andfields[1]panics withindex out of range [1]. The per-catalogerrecoverthen swallows the panic and yields zero Haskell packages for the entire scan.Reproducible on any real freeze file (e.g.
cabal init -n && cabal freeze), which is the same repro from the previously-closed #1362 — that fix guarded a different index and the panic simply moved tofields[1].Fix
Skip constraint lines without a version (
len(fields) < 2) soinstalledboot-lib lines are ignored and the remaining== versionpackages parse normally.Test
Extended
testdata/cabal.project.freezewithany.array installed,/any.base installed,. The existing exact-set assertion inparse_cabal_freeze_test.gois now a regression guard: it passes only if theinstalledlines are skipped and every real package still parses. Before the fix the fixture panicked.