Skip to content

CodeCompliance: send a User-Agent from IsDocumentationURLValid - #562

Merged
IsakNaslundBh merged 4 commits into
developfrom
CodeComplianceTest_Engine-#561-DocumentationURLUserAgent-minimal
Nov 25, 2026
Merged

IsakNaslundBh merged 4 commits into
developfrom
CodeComplianceTest_Engine-#561-DocumentationURLUserAgent-minimal

Conversation

@sakanni

@sakanni sakanni commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Issues addressed by this PR

Closes #561

IsDocumentationURLValid sent its request with no User-Agent, and some sites refuse those. rics.org returns 403 to an empty or curl User-Agent and 200 to the User-Agent this check now sends, from both GitHub-hosted runners and a local machine, so valid links failed CI.

The check now sends BHoM-ComplianceCheck/1.0 with a link to its documentation page, and passes on any 2xx rather than only 200. It uses one shared client with a 30 second timeout instead of a new client per attribute. The client closes each connection after use, so a long-lived host such as Grasshopper never holds pooled connections or stale DNS results, at negligible cost for the handful of links a check makes. Responses are read headers-first, so a 2xx passes without downloading the page body. Any exception still fails the link, as before.

Test files

New NUnit project .ci/unit-tests/CodeComplianceTest_Engine_Tests, added to Test_Toolkit_Tests.sln. It runs against a local HTTP listener, apart from one test that relies on the .invalid domain never resolving (RFC 6761). Three of its seven tests fail on develop (204, a site that needs a User-Agent, and the User-Agent itself) and all seven pass here. Two of them check that an ftp:// link and an unresolvable host still fail without throwing. Existing tests are unchanged. The new project is not yet run by this repository's CI.

Changelog

  • IsDocumentationURLValid identifies itself with a User-Agent and accepts any 2xx response.

Additional comments

Reporting 403 and 429 as a warning instead of an error was considered and left out. With the User-Agent, the RICS link passes from GitHub runners and locally, and every other [DocumentationURL] link found in BHoM passes when checked locally. A warning never blocks, so a link that is genuinely dead behind a site that answers 403 would go green.

Not in this PR: the check reads the URL from the attribute's source text, so a valid URL written as a verbatim string, a constant or a named argument still fails as a broken link. That limitation predates this change and is unaffected by it.

Not tested: inside a real Grasshopper host, and under BHoMBot.

@sakanni

sakanni commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@BHoMBot check required

@sakanni
sakanni marked this pull request as ready for review November 18, 2026 10:29
@bhombot-ci

bhombot-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown

@sakanni to confirm, the following actions are now queued:

  • check code-compliance
  • check documentation-compliance
  • check project-compliance
  • check core
  • check null-handling
  • check serialisation
  • check versioning
  • check installer

There are 1 requests in the queue ahead of you.

@bhombot-ci

bhombot-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown

This repository is not part of the beta package and does not require a versioning check to be performed.

@bhombot-ci

bhombot-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown

This repository is not part of the installer package, and does not require an installer check.

@sakanni sakanni added the type:bug Error or unexpected behaviour label Nov 18, 2026
@sakanni

sakanni commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@BHoMBot check copyright-compliance

@bhombot-ci

bhombot-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown

@sakanni to confirm, the following actions are now queued:

  • check copyright-compliance

@sakanni sakanni assigned sakanni and unassigned IsakNaslundBh Nov 18, 2026
@sakanni

sakanni commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

@BHoMBot check versioning
@BHoMBot check null-handling
@BHoMBot check documentation-compliance

@bhombot-ci

bhombot-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown

@sakanni to confirm, the following actions are now queued:

  • check versioning
  • check null-handling
  • check documentation-compliance

@bhombot-ci

bhombot-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown

This repository is not part of the beta package and does not require a versioning check to be performed.

@sakanni

sakanni commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

@BHoMBot check null-handling

@bhombot-ci

bhombot-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown

@sakanni to confirm, the following actions are now queued:

  • check null-handling

@bhombot-ci

bhombot-ci Bot commented Nov 18, 2026

Copy link
Copy Markdown

@sakanni to confirm, the following actions are now queued:

  • check null-handling

There are 185 requests in the queue ahead of you.

@sakanni

sakanni commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@BHoMBot check documentation-compliance

@bhombot-ci

bhombot-ci Bot commented Nov 25, 2026

Copy link
Copy Markdown

@sakanni to confirm, the following actions are now queued:

  • check documentation-compliance

There are 89 requests in the queue ahead of you.

@sakanni

sakanni commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

@BHoMBot check copyright-compliance
@BHoMBot check project-compliance
@BHoMBot check serialisation

@bhombot-ci

bhombot-ci Bot commented Nov 25, 2026

Copy link
Copy Markdown

@sakanni to confirm, the following actions are now queued:

  • check copyright-compliance
  • check project-compliance
  • check serialisation

There are 88 requests in the queue ahead of you.

@IsakNaslundBh IsakNaslundBh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Happy with this. Tested with my previously not functioning case, and this now passes.

@IsakNaslundBh
IsakNaslundBh merged commit 6454ca0 into develop Nov 25, 2026
8 checks passed
@IsakNaslundBh
IsakNaslundBh deleted the CodeComplianceTest_Engine-#561-DocumentationURLUserAgent-minimal branch November 25, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type:bug Error or unexpected behaviour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CodeCompliance: IsDocumentationURLValid fails for sites that reject requests without a User-Agent

2 participants