Repository navigation
Read API error details without an undeclared import, fix a null crash, add tests - #7
Merged
Merged
Conversation
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files
|
There was a problem hiding this comment.
🟢 Approval recommended
The dependency declaration and lockfile update are consistent, complete, and runtime-neutral.
Pull request overview
Declares the existing RequestError type dependency explicitly, removing reliance on transitive npm hoisting without changing runtime behavior.
Changes:
- Converts
RequestErrorto a type-only import. - Adds and locks
@octokit/request-errorat^5.1.1.
File summaries
| File | Description |
|---|---|
src/main.ts |
Uses an explicit type-only import. |
package.json |
Declares the direct development dependency. |
package-lock.json |
Synchronizes root dependency metadata. |
Review details
- Files reviewed: 2/3 changed files
- Comments generated: 0
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
#3 started reporting the more specific message the GitHub API sometimes puts in
response.data.errors. It had two flaws:RequestErrorfrom@octokit/request-error, which is not declared inpackage.jsonand only resolved because npm hoists it out of@actions/github.response.datais an object. Whendataisnull, the catch blockthrows a
TypeErrorthat replaces the real error.What this changes
A new
getApiErrorMessageinsrc/utils.tschecks each field before reading it.It prefers
response.data.errorswhen that is a string, thenerror.message, thenString(error). The undeclared import is gone. Eleven tests intests/utils.test.jscover it, using Node's built-in runner, no framework added.Who is affected
Normal API error messages are unchanged. Unusual failures now report the real
message instead of a crash or an empty one:
nullor non-objectdata, a missingresponse, and thrown values that are not anError, such as a string ornull.Notes
@octokit/request-error: the code reads one field, theas RequestErrorcast gave no runtime safety, and a direct dependency can driftfrom the version
@actions/githubpins, leaving two copies installed.globalsis a new devDependency, used only by ESLint.no-undefstays on for theplain JS tests, and the first
consoleorprocessin a test would fail lintwithout it.
tsconfig.jsonpinsrootDirto./src, so a stray.tsfile intests/canno longer move the output to
lib/src/and breakncc's entry point.npm testbuilds first.npm run allalso runs the tests, so CI picks them up.CONTRIBUTING.mdgains a note on testing a change against a builtdist/branch.dist/is left out and is rebuilt bybuild.ymlafter merge.