Skip to content

stackage: fall back to sha256 when sha1 is missing in stack-setup-2.yaml#196

Merged
shankerwangmiao merged 1 commit intotuna:masterfrom
yaoge123:fix/stackage-sha256-fallback
May 4, 2026
Merged

stackage: fall back to sha256 when sha1 is missing in stack-setup-2.yaml#196
shankerwangmiao merged 1 commit intotuna:masterfrom
yaoge123:fix/stackage-sha256-fallback

Conversation

@yaoge123
Copy link
Copy Markdown
Contributor

@yaoge123 yaoge123 commented May 4, 2026

Problem

Upstream stack-setup-2.yaml (from commercialhaskell/stackage-content) has 921 GHC entries, but 8 entries under the freebsd64-ino64 platform (versions 9.8.1 through 9.12.2) only provide sha256 checksums without sha1.

The script hardcoded d['ghc'][platform][ver]['sha1'], causing a KeyError and sync failure whenever these entries appear.

KeyError: 'sha1'
  File "stackage.py", line 51, in load_stack_setup
    d['ghc'][platform][ver]['sha1'],

Fix

  • download() now accepts an optional sha256 keyword argument
  • When sha1 is available, sha-1 checksum is used (backward compatible)
  • When sha1 is missing but sha256 is present, sha-256 is used instead
  • When neither is available, download proceeds without checksum verification
  • The call site uses meta.get() for graceful degradation

Tested

  • Verified against the full 921-entry stack-setup-2.yaml
  • 913 existing entries with sha1 continue to use sha-1 verification (unchanged)
  • 8 new freebsd64-ino64 entries with only sha256 now use sha-256 verification
  • Sync completed successfully at NJU mirror with this fix applied

Copilot AI review requested due to automatic review settings May 4, 2026 01:54
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Stackage mirror sync script to handle newer stack-setup-2.yaml entries that omit sha1 and provide only sha256, so syncing can continue for affected GHC metadata instead of failing with a KeyError.

Changes:

  • Extend StackageSession.download() to accept an optional sha256 checksum and pass it to aria2c when sha1 is absent.
  • Read each GHC entry into meta and switch checksum lookup from hardcoded ['sha1'] access to meta.get(...) for graceful handling of mixed checksum formats.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread stackage.py Outdated
Comment on lines +54 to +55
sha1=meta.get('sha1'),
sha256=meta.get('sha256'),
Some GHC entries in upstream stack-setup-2.yaml (freebsd64-ino64 platform,
versions 9.8.1 through 9.12.2) only provide sha256 without sha1.  Previously
the script hardcoded sha1 access, causing KeyError.

- download() now accepts optional sha256, falls back to sha-256 checksum
- load_stack_setup() explicitly selects sha1 or sha256; entries with
  neither checksum are skipped with a warning
@yaoge123 yaoge123 force-pushed the fix/stackage-sha256-fallback branch from 88e92e0 to afe1779 Compare May 4, 2026 02:03
@yaoge123
Copy link
Copy Markdown
Contributor Author

yaoge123 commented May 4, 2026

Good point — the call site should explicitly select sha1 or sha256 rather than silently allowing both to be None. Updated in the force-pushed commit: load_stack_setup() now picks the checksum algorithm explicitly and skips entries (with a warning) when neither checksum is available.

@shankerwangmiao shankerwangmiao merged commit bceeafc into tuna:master May 4, 2026
13 of 15 checks passed
@yaoge123 yaoge123 deleted the fix/stackage-sha256-fallback branch May 4, 2026 13:38
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.

3 participants