Skip to content

Fix pattern matching in do_latest_file_size_by_head - #162

Closed
mattwynne wants to merge 1 commit into
lau:masterfrom
mechanical-orchard:fix-not-using-head-for-size-pattern-match-bug
Closed

mattwynne wants to merge 1 commit into
lau:masterfrom
mechanical-orchard:fix-not-using-head-for-size-pattern-match-bug

Conversation

@mattwynne

Copy link
Copy Markdown
Contributor

Fix where pattern matching expected a flat 3-tuple {tag, status, headers} but HTTPClient behaviour returns nested structure {:ok, {status, headers}}.

This causes a FunctionClauseError when calling latest_file_size_by_head, silently falling back to GET requests.

Adds Sham (and Bandit) as test-only deps to allow for testing the change.

Licensing: This contribution is made by employees of Mechanical Orchard, Inc. under the terms of the project’s license.

Fix where pattern matching expected a flat
3-tuple {tag, status, headers} but HTTPClient behaviour
returns nested structure {:ok, {status, headers}}.

This causes a FunctionClauseError when calling
latest_file_size_by_head, silently falling back to GET requests.

Adds sham to allow for testing

Co-authored-by: Ryan Spore <ryan@mechanical-orchard.com>
acrogenesis added a commit to valiot/tzdata that referenced this pull request Jun 9, 2026
…ers}} HEAD shape

The HTTP client contract (both Hackney and Req) returns {:ok, {status, headers}}
from head/3, but do_latest_file_size_by_head/1 matched a 3-tuple
({_tag, resp_code, _headers}), so a successful HEAD matched no clause and raised
FunctionClauseError. This is the HEAD-based file-size path used by the release
updater when the loaded release has no modified_at timestamp. Match the actual
shape instead. Adapted from lau#162; adds an offline regression test
using a stub HTTP client (no extra test deps).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lau

lau commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Thanks. Replaced by this because of git conflicts: #191

@lau lau closed this Sep 26, 2026
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