Skip to content

XS✔ ◾ Fix Small Bugs and Remove Test Mock Artifact#783

Open
muiriswoulfe wants to merge 15 commits intomainfrom
fix/small-bug-fixes-2
Open

XS✔ ◾ Fix Small Bugs and Remove Test Mock Artifact#783
muiriswoulfe wants to merge 15 commits intomainfrom
fix/small-bug-fixes-2

Conversation

@muiriswoulfe
Copy link
Copy Markdown
Member

@muiriswoulfe muiriswoulfe commented Apr 10, 2026

Summary

  • azureReposInvoker.ts / gitHubReposInvoker.ts: Reject blank and whitespace-only access tokens.
  • baseReposInvoker.ts: Separate HTTP 404 from 401/403 with distinct localised error message.
  • codeMetrics.ts: Remove endingToRemove block (test mock artefact) and fix test.
  • consoleWrapper.ts: Sanitise newlines to prevent log injection.
  • gitHubReposInvoker.ts: Make Link header regex more permissive for pagination.
  • httpWrapper.ts: Add HTTP error check and abort timeout (30 s).
  • inputs.ts: Trim lines and filter empty entries after splitting.
  • logger.ts: try/catch JSON.stringify; redact sensitive properties; sanitise newlines.
  • octokitGitDiffParser.ts: Add binary file guard for RenamedFile; replace for/push with .map().
  • pullRequest.ts: Fix isPullRequest to check GITHUB_BASE_REF is defined.
  • pullRequestMetrics.ts: Guard error cast with instanceof Error; replay logger in both branches.
  • tokenManager.ts: Move _previouslyInvoked after successful token acquisition.

@muiriswoulfe
Copy link
Copy Markdown
Member Author

muiriswoulfe commented Apr 10, 2026

PR Metrics

Thanks for keeping your pull request small.
Thanks for adding tests.

Lines
Product Code 111
Test Code 211
Subtotal 322
Ignored Code 6
Total 328

Metrics computed by PR Metrics. Add it to your Azure DevOps and GitHub PRs!

@muiriswoulfe muiriswoulfe changed the title Fix Small Bugs and Remove Test Mock Artifact XS✔ ◾ Fix Small Bugs and Remove Test Mock Artifact Apr 10, 2026
@muiriswoulfe
Copy link
Copy Markdown
Member Author

Super-linter summary

Language Validation result
BIOME_LINT Pass ✅
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
JSON_PRETTIER Pass ✅
MARKDOWN Pass ✅
MARKDOWN_PRETTIER Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
TYPESCRIPT_PRETTIER Pass ✅
XML Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

This parameter has no effect on GitHub because GitHub issue/review
comments have no Active/Closed thread status. It only applies to
Azure DevOps, where it is already defined in task.json.
@muiriswoulfe
Copy link
Copy Markdown
Member Author

Super-linter summary

Language Validation result
BIOME_LINT Pass ✅
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
JSON_PRETTIER Pass ✅
MARKDOWN Pass ✅
MARKDOWN_PRETTIER Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
TYPESCRIPT_PRETTIER Pass ✅
XML Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

@muiriswoulfe
Copy link
Copy Markdown
Member Author

Super-linter summary

Language Validation result
BIOME_LINT Pass ✅
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
JSON_PRETTIER Pass ✅
MARKDOWN Pass ✅
MARKDOWN_PRETTIER Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
TYPESCRIPT_PRETTIER Pass ✅
XML Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves robustness and diagnostics across the PR Metrics task (GitHub Action + Azure DevOps task) by tightening error handling, input parsing, and diff parsing, while also cleaning up a test-only artifact in metrics parsing.

Changes:

  • Add safer operational guards (HTTP timeouts/status checks, binary diff handling, non-Error throws handling).
  • Improve security/diagnostics (error-property redaction, clearer 404 messaging, stricter access-token presence checks).
  • Remove a test mock artifact from CodeMetrics parsing and update/extend unit tests accordingly.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/task/src/wrappers/httpWrapper.ts Adds request timeout + response.ok validation for diff downloads.
src/task/src/utilities/constants.ts Introduces a shared HTTP timeout constant.
src/task/src/utilities/logger.ts Adds sensitive-field redaction + safe serialization for error logging.
src/task/src/repos/tokenManager.ts Allows retry by only marking invocation after successful token acquisition.
src/task/src/repos/gitHubReposInvoker.ts Rejects empty tokens; relaxes Link header parsing for pagination.
src/task/src/repos/azureReposInvoker.ts Rejects empty tokens.
src/task/src/repos/baseReposInvoker.ts Splits 404 handling from 401/403 with a distinct message.
src/task/src/pullRequests/pullRequest.ts Fixes GitHub PR detection when GITHUB_BASE_REF is undefined.
src/task/src/pullRequestMetrics.ts Handles non-Error thrown values when failing the task.
src/task/src/metrics/inputs.ts Trims per-line values for patterns/extensions inputs.
src/task/src/metrics/codeMetrics.ts Removes mock-only output stripping and updates error message text accordingly.
src/task/src/git/octokitGitDiffParser.ts Skips renamed binary files; simplifies diff splitting via .map().
action.yml Adds always-close-comment input definition for the GitHub Action.
src/task/tests/utilities/logger.spec.ts Adds tests for redaction and non-serializable error properties.
src/task/tests/repos/gitHubReposInvoker.spec.ts Updates assertions for new 404 error messaging behavior.
src/task/tests/repos/azureReposInvoker.spec.ts Updates assertions for new 404 error messaging behavior.
src/task/tests/pullRequestMetrics.spec.ts Adds coverage for non-Error thrown values.
src/task/tests/metrics/codeMetrics.spec.ts Updates test data to match removal of mock artifact stripping.
src/task/tests/git/octokitGitDiffParser.spec.ts Adds coverage for renamed binary file handling.

@muiriswoulfe
Copy link
Copy Markdown
Member Author

Super-linter summary

Language Validation result
BIOME_LINT Pass ✅
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
JSON_PRETTIER Pass ✅
MARKDOWN Pass ✅
MARKDOWN_PRETTIER Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
TYPESCRIPT_PRETTIER Pass ✅
XML Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

@muiriswoulfe
Copy link
Copy Markdown
Member Author

Super-linter summary

Language Validation result
BIOME_LINT Pass ✅
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
JSON_PRETTIER Pass ✅
MARKDOWN Pass ✅
MARKDOWN_PRETTIER Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
TYPESCRIPT_PRETTIER Pass ✅
XML Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

@microsoft microsoft deleted a comment from muiriswoulfe Apr 10, 2026
@microsoft microsoft deleted a comment from muiriswoulfe Apr 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 3 comments.

@muiriswoulfe
Copy link
Copy Markdown
Member Author

Super-linter summary

Language Validation result
BIOME_LINT Pass ✅
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
JSON_PRETTIER Pass ✅
MARKDOWN Pass ✅
MARKDOWN_PRETTIER Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
TYPESCRIPT_PRETTIER Pass ✅
XML Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

Copilot AI review requested due to automatic review settings April 10, 2026 16:25
@muiriswoulfe
Copy link
Copy Markdown
Member Author

Super-linter summary

Language Validation result
BIOME_LINT Pass ✅
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
JSON_PRETTIER Pass ✅
MARKDOWN Pass ✅
MARKDOWN_PRETTIER Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
TYPESCRIPT_PRETTIER Pass ✅
XML Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

@muiriswoulfe
Copy link
Copy Markdown
Member Author

Super-linter summary

Language Validation result
BIOME_LINT Pass ✅
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
JSON_PRETTIER Pass ✅
MARKDOWN Pass ✅
MARKDOWN_PRETTIER Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
TYPESCRIPT_PRETTIER Pass ✅
XML Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 1 comment.

Use a JSON replacer to redact nested sensitive properties (e.g.
request.headers.authorization) during serialization, not just
top-level property names.
@muiriswoulfe
Copy link
Copy Markdown
Member Author

Super-linter summary

Language Validation result
BIOME_LINT Pass ✅
CHECKOV Pass ✅
EDITORCONFIG Pass ✅
GITHUB_ACTIONS Pass ✅
GITHUB_ACTIONS_ZIZMOR Pass ✅
GITLEAKS Pass ✅
GIT_MERGE_CONFLICT_MARKERS Pass ✅
JSCPD Pass ✅
JSON_PRETTIER Pass ✅
MARKDOWN Pass ✅
MARKDOWN_PRETTIER Pass ✅
NATURAL_LANGUAGE Pass ✅
POWERSHELL Pass ✅
PRE_COMMIT Pass ✅
SPELL_CODESPELL Pass ✅
TRIVY Pass ✅
TYPESCRIPT_PRETTIER Pass ✅
XML Pass ✅
YAML Pass ✅
YAML_PRETTIER Pass ✅

All files and directories linted successfully

For more information, see the GitHub Actions workflow run

Powered by Super-linter

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.

3 participants