Skip to content

Fix #10252: cabal upload fails with curl chunked-encoding error - #12211

Merged
mergify[bot] merged 8 commits into
haskell:masterfrom
tusharad:fix/cabal-upload-fail
Aug 17, 2026
Merged

Fix #10252: cabal upload fails with curl chunked-encoding error#12211
mergify[bot] merged 8 commits into
haskell:masterfrom
tusharad:fix/cabal-upload-fail

Conversation

@tusharad

@tusharad tusharad commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #10252.

Description

Newer versions of curl misinterpret the literal \n character embedded within the --write-out "\n%{http_code}" argument during chunked-encoding transfers (such as POST and PUT requests used in cabal upload). This results in curl: (56) Illegal or missing hexadecimal sequence in chunked-encoding errors.

This PR:

  • Removes the newline character from the --write-out parameter for both posthttpfile and puthttpfile.
  • Adjusts parseResponse in curlTransport (and extracts it as parseCurlResponse) to extract the 3-digit HTTP status code directly from the end of the response string, avoiding the need to split the string by lines.
  • Adds test cases for parseCurlResponse in UnitTests.Distribution.Client.HttpUtils.

QA Notes

Calling cabal upload <package>.tar.gz on a system with a newer version of curl installed should succeed without throwing a curl: (56) chunked-encoding error, correctly parsing the upload status code.


Template Α: This PR modifies behaviour or interface

@tusharad tusharad changed the title test: add unit tests for parseCurlResponse and refactor logic into an exported function Fix #10252: cabal upload fails with curl chunked-encoding error Aug 4, 2026
@ffaf1

ffaf1 commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Hello and thanks for your contribution.

This PR is missing a template (here).

@ulysses4ever

ulysses4ever commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

wow, if this really fixes it, it's a big one. Maybe we should even consider a lightning 3.18.1.1. release.. And it only touches the tool

@Mikolaj

Mikolaj commented Aug 6, 2026

Copy link
Copy Markdown
Member

Yay! BTW, a changelog snippet would also be welcome.

@tusharad

tusharad commented Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

@Mikolaj

Mikolaj commented Aug 7, 2026

Copy link
Copy Markdown
Member

@ulysses4ever

Copy link
Copy Markdown
Collaborator

Will do. Hopefully on the weekend

@ulysses4ever

Copy link
Copy Markdown
Collaborator

cabal upload .tar.gz on a system with a newer version of curl installed should succeed

Is three any info on which curl do and don't work? Does this patch support both of these cases or only newer curl?

@ffaf1 ffaf1 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I left some comments. I am aware not all code is yours, some is just shuffled around, but if we are refactoring stuff (good!) it might be a good opportunity to clean some code.

Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs Outdated
Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs Outdated
Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs Outdated
Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs Outdated
Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs Outdated
Comment thread cabal-install/tests/UnitTests/Distribution/Client/HttpUtils.hs Outdated
Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs Outdated

@ulysses4ever ulysses4ever left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

We could have merged it in an instant if you had just kicked out the \n. Instead, you introduced a subtle refactoring that'a completely unrelated, and we'll spend much more time reviewing it. Please, don't introduce unrelated changes in one PR especially when you're fixing high-priority bugs like this one.

The best way to proceed would be to reset this patch to a state when it only removes the \n. And leave all rest for another PR. I'm not saying you must do it, it's just the easiest and most effective. But if you prefer keeping it as one PR, we can work with it.

Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs Outdated
Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs Outdated
Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs
Comment thread cabal-install/src/Distribution/Client/HttpUtils.hs Outdated
@tusharad

tusharad commented Aug 8, 2026

Copy link
Copy Markdown
Contributor Author

Hello @ulysses4ever and @ffaf1
Thank you for the detailed review, either I'll try to fix them or create a new PR for this. Meanwhile please a look at this.

https://github.com/tusharad/sql2er/actions/runs/31257218055 - Seems like curl 7.6 to 8.5 are breaking while passing on latest cabal.

my fixed is passing on all - https://github.com/tusharad/sql2er/actions/runs/31257224015

Btw on my mac, the issue is not appearing at all. Linux specific?

@tusharad
tusharad force-pushed the fix/cabal-upload-fail branch from 03a4df4 to 2e9536d Compare August 8, 2026 13:03
@tusharad
tusharad requested review from ffaf1 and ulysses4ever August 8, 2026 16:41
@ffaf1

ffaf1 commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

[x] Tests have been added.

There are no tests in this PR.

@tusharad
tusharad force-pushed the fix/cabal-upload-fail branch 2 times, most recently from 723e949 to e2d6813 Compare August 10, 2026 10:17
@tusharad
tusharad force-pushed the fix/cabal-upload-fail branch from 49ef270 to 24f4aa8 Compare August 10, 2026 10:23
@tusharad

tusharad commented Aug 10, 2026

Copy link
Copy Markdown
Contributor Author

[x] Tests have been added.

There are no tests in this PR.

My bad, the commit revert had it removed. Added them now. @ffaf1

@tusharad

Copy link
Copy Markdown
Contributor Author

@ffaf1 I think it can be merged?

@ffaf1 ffaf1 added the squash+merge me Tell Mergify Bot to squash-merge label Aug 15, 2026
@ffaf1

ffaf1 commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Sure, I have put the merge me label, now mergify will take care of it in two days (the buffer period this project has for additional feedback).

@mergify mergify Bot added ready and waiting Mergify is waiting out the cooldown period merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days queued labels Aug 15, 2026
@mergify

mergify Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 55 minutes 11 seconds in the queue, including 1 hour 40 minutes 55 seconds running CI.

Required conditions to merge
  • #review-threads-unresolved = 0 [🛡 GitHub branch protection]
  • github-review-approved [🛡 GitHub branch protection]
  • any of [🛡 GitHub branch protection]:
    • check-success = Doctest Cabal
    • check-neutral = Doctest Cabal
    • check-skipped = Doctest Cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Meta checks
    • check-neutral = Meta checks
    • check-skipped = Meta checks
  • any of [🛡 GitHub branch protection]:
    • check-success = docs/readthedocs.org:cabal
    • check-neutral = docs/readthedocs.org:cabal
    • check-skipped = docs/readthedocs.org:cabal
  • any of [🛡 GitHub branch protection]:
    • check-success = Validate post job
    • check-neutral = Validate post job
    • check-skipped = Validate post job
  • any of [🛡 GitHub branch protection]:
    • check-success = fourmolu
    • check-neutral = fourmolu
    • check-skipped = fourmolu
  • any of [🛡 GitHub branch protection]:
    • check-success = hlint
    • check-neutral = hlint
    • check-skipped = hlint
  • any of [🛡 GitHub branch protection]:
    • check-success = Bootstrap post job
    • check-neutral = Bootstrap post job
    • check-skipped = Bootstrap post job
  • any of [🛡 GitHub branch protection]:
    • check-success = whitespace
    • check-neutral = whitespace
    • check-skipped = whitespace
  • any of [🛡 GitHub branch protection]:
    • check-success = Check sdist post job
    • check-neutral = Check sdist post job
    • check-skipped = Check sdist post job
  • any of [🛡 GitHub branch protection]:
    • check-success = Changelogs
    • check-neutral = Changelogs
    • check-skipped = Changelogs

@mergify
mergify Bot merged commit ca805f1 into haskell:master Aug 17, 2026
69 checks passed
@mergify mergify Bot removed the queued label Aug 17, 2026
@zlonast

zlonast commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

@mergify backport 3.18

@mergify

mergify Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

backport 3.18

✅ Backports have been created

Details

mergify Bot added a commit that referenced this pull request Aug 29, 2026
Backport #12211: Fix #10252: cabal upload fails with curl chunked-encoding error
Mikolaj pushed a commit to Mikolaj/cabal that referenced this pull request Sep 10, 2026
haskell#12211)

* fix: remove newline from curl --write-out option in posthttpfile and puthttpfile

* test: add unit tests for HttpUtils and document fix for curl chunked-encoding upload failures

* chore: update synopsis for cabal upload error fix in changelog

* refactor: update HTTP status code extraction to parse the last three characters of the response body

* docs: clarify status code extraction logic in HttpUtils curl response parsing

(cherry picked from commit ca805f1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attention: needs-backport 3.18 merge delay passed Applied (usually by Mergify) when PR approved and received no updates for 2 days ready and waiting Mergify is waiting out the cooldown period squash+merge me Tell Mergify Bot to squash-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cabal upload throwing curl errors

5 participants