Handle wildcard paths to external content sources; check redirects - #740
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved path-matching and redirect-status issues remain, and GET fallback coverage is missing.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates DocsVerifier to handle wildcard external content paths and validate redirects with GET fallback.
Changes:
- Adds wildcard-parent matching for external sources.
- Falls back from redirected
HEADrequests toGET. - Adds regression coverage for wildcard paths.
File summaries
| File | Summary |
|---|---|
actions/docs-verifier/tests/GitHub.UnitTests/PathVerifierTests.cs |
Adds wildcard external-source path tests. |
actions/docs-verifier/src/RedirectionVerifier/RedirectTargetVerifier.cs |
Restrict fallback handling to actual redirects or responses with Location; add HTTP-backed coverage for the HEAD-to-GET path. Moderate (1 vote), nit (1 vote). |
actions/docs-verifier/src/DocfxVerifier/PathVerifier.cs |
Use case-insensitive comparisons and apply ancestor matching only to wildcard metadata keys. Moderate (1 vote), moderate (3 votes). |
Review details
Suppressed comments (3)
actions/docs-verifier/src/DocfxVerifier/PathVerifier.cs:329
- These comparisons use ordinal case-sensitive matching, while DocFX config content matching is explicitly
StringComparison.OrdinalIgnoreCase(actions/docs-verifier/src/RedirectionVerifier/DocfxConfiguration.cs:36). An externalsrcand itsfileMetadataglob that differ only by case are therefore reported as invalid even though DocFX treats them as the same path; use the case-insensitive comparison consistently here.
if (pathPrefix.Equals(sourceDirectory, StringComparison.Ordinal)
|| pathPrefix.StartsWith(sourceDirectory + "/", StringComparison.Ordinal)
|| sourceDirectory.StartsWith(pathPrefix + "/", StringComparison.Ordinal))
actions/docs-verifier/src/RedirectionVerifier/RedirectTargetVerifier.cs:124
- The numeric range includes
300 MultipleChoices,304 NotModified, and305 UseProxy, which are not redirect responses. For those statuses this causes an unnecessary GET and can replace a reachable 3xx result with a method-specific 404 or other failure; restrict the helper to actual redirect codes (301/302/303/307/308), or require aLocationheader.
int code = (int)statusCode;
return code >= 300 && code < 400;
actions/docs-verifier/src/RedirectionVerifier/RedirectTargetVerifier.cs:102
- The new HEAD-3xx-to-GET fallback is not exercised by the existing tests: every RedirectTargetVerifier test injects
statusCodeProvider, soGetStatusCodeAsyncand this branch never run. Add an HttpMessageHandler-backed test (or equivalent HTTP-client injection) that verifies a redirect followed by a working target and a redirect followed by 404 use the GET result.
if (headResponse.StatusCode is HttpStatusCode.MethodNotAllowed or HttpStatusCode.NotImplemented or HttpStatusCode.NotFound
|| IsRedirectStatusCode(headResponse.StatusCode))
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
wadepickett
left a comment
There was a problem hiding this comment.
@gewarren: Approved. Looks good. Copilot found one edge case issue. Worth fixing it seems. Somewhat low to moderate issue.
Contributes to #738