Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#295] fix failing with OverlongHeaders #315

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vlad1028
Copy link

@vlad1028 vlad1028 commented Jan 20, 2025

Description

Problem:
xrefcheck was failing with OverlongHeaders, making it impossible to validate web pages (e.g., Notion pages) that respond with too long headers.

Solution:
I added a configurable parameter, ncMaxHeaderLength, allowing users to define the maximum header length that xrefcheck can handle.

To achieve this, I added a new field, ncHttpManager, which contains configurations related to OverlongHeaders. This field is purely internal and cannot be configured by users. Reusing a single Manager for the project provides maximal connection sharing.

Related issue(s)

Fixes #295

✅ Checklist for your Pull Request

Ideally a PR has all of the checkmarks set.

If something in this list is irrelevant to your PR, you should still set this
checkmark indicating that you are sure it is dealt with (be that by irrelevance).

Related changes (conditional)

  • Tests

    • If I added new functionality, I added tests covering it.
    • If I fixed a bug, I added a regression test to prevent the bug from
      silently reappearing again.
  • Documentation

    • I checked whether I should update the docs and did so if necessary:
  • Public contracts

    • Any modifications of public contracts comply with the Evolution
      of Public Contracts
      policy.
    • I added an entry to the changelog if my changes are visible to the users
      and
    • provided a migration guide for breaking changes if possible

Stylistic guide (mandatory)

✓ Release Checklist

  • I updated the version number in package.yaml.
  • I updated the changelog and moved everything
    under the "Unreleased" section to a new section for this release version.
  • (After merging) I edited the auto-release.
    • Change the tag and title using the format vX.Y.Z.
    • Write a summary of all user-facing changes.
    • Deselect the "This is a pre-release" checkbox at the bottom.
  • (After merging) I updated xrefcheck-action.
  • (After merging) I uploaded the package to hackage.

Problem: xrefcheck may fail with OverlongHeaders making it impossible to check a given file.

Solution: make it possible to configure max header length for responses that xrefcheck is handling.
metavar "INT" <>
value Nothing <>
help "The maximum allowed total size of HTTP headers (in bytes) \
\ that can be returned by the server."
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: you insert two spaces between (in bytes) and that. I would strip the one before that.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, let's strip extending CLI options. The code is good, the reason is that, in this project, CLI arguments serve to tune how verification is run, and config serves to tune which set of errors should be covered. If I run xrefcheck for the first time on any given project, I shouldn't need to know that I have to specify --header-limit option.

So having header length limit specified in config should suffice.

{ cNetworking = addNetworkingOptions (cNetworking config) oNetworkingOptions }

mgr <- newManager $ managerSetMaxHeaderLength (ncMaxHeaderLength (cNetworking parsedConfig)) tlsManagerSettings
let fullConfig = parsedConfig & cNetworkingL . ncHttpManagerL .~ Just mgr
Copy link
Member

Choose a reason for hiding this comment

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

I think it's better not to mix config and things created at runtime, and propagate the manager as separate argument. Shouldn't require too much chances as far as I can tell.

@@ -164,6 +166,7 @@ tests:
- tasty
- tasty-hunit
- tasty-quickcheck
- text
- time
- universum
- uri-bytestring
Copy link
Member

Choose a reason for hiding this comment

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

Just global comment: Make sure commit names start with uppercase, and use infinitive.

  • [#xxx] Fix OverlongHeaders
  • [#xxx] Add tests

Other than that, looks good, thanks for using Problem/Solution template for commit description 👍

@Martoon-00
Copy link
Member

Thanks for bringing this PR, really good job. Code is good and close to what I'd expect here.

I'm leaving a few comments related to our coding practices and direction of this project. And yet to check the tests a bit later.

@Martoon-00 Martoon-00 closed this Jan 24, 2025
@Martoon-00 Martoon-00 reopened this Jan 24, 2025
@Martoon-00
Copy link
Member

Oh my apologies, I misclicked and closed the PR by accident.

Wanted to say just in case, feel free to address review requests after the weekends.

[ VerifyLinkTestEntry
{ vlteConfigModifier = \c -> c
& cNetworkingL . ncMaxHeaderLengthL .~ mhl
& cNetworkingL . ncHttpManagerL .~ Just mgr
Copy link
Member

Choose a reason for hiding this comment

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

If manager will be not part of config, its creation will likely be somewhere inside checkMultipleLinksWithServer, maybe right in verifyReferenceWithProgress even.

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.

[BUG] xrecheck may fail with OverlongHeaders
2 participants