Repository navigation
fix(railway-redeploy): report missing inputs through setFailed - #15
Merged
Merged
Conversation
main() read its required inputs before its try block, and the entry point called main() without a catch. A missing input threw from core.getInput, the promise rejection went unhandled, and Node crashed: the log showed the whole minified dist/index.js line and a stack trace, with no ::error:: annotation. Move the catch onto the main() call, so every error main() throws, input reads included, goes through core.setFailed with the action's usual message. Add the action's first unit test, which runs the entry point without each required input, and the test task that runs it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ELZQC2WCLnTiM4Fd7nKdcE
|
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.
Summary
main()read its required inputs before itstry, and the entry point calledmain()with no.catch. A missing input threw fromcore.getInput, the rejection went unhandled, and Node crashed without a::error::annotation.The catch now sits on the call, so everything
main()throws, input reads included, goes throughcore.setFailed:async function main() { const projectId = core.getInput("project_id", { required: true }); // throws when missing ... - try { - ...redeploy... - } catch (error) { - core.setFailed(`🚨 Failed to redeploy railway service: ${error.message}`); - } + ...redeploy... } -main(); +main().catch((error) => { + core.setFailed(`🚨 Failed to redeploy railway service: ${error.message}`); +});src/index.tsdiff is mostly the dedent of the oldtrybody:git diff -wshows the real change. The action also gets its first unit test (src/index.test.ts) and thetesttask in itsmise.toml, somise run test, the pre-push hook and CI pick it up.dist/is rebuilt withmise run check-dist.Evidence
Before:
node dist/index.jswithoutINPUT_PROJECT_IDprints the whole minifieddist/index.jsline (~115 KB of log) and a stack trace, exit 1, no annotation:After:
Test: for each of
project_id,environment,service_name,api_token, run the entry point without it and expect exit 1 and that::error::line on stdout. On the oldsrc/index.ts: 4 failed. With the fix: 4 passed.mise run check,mise run test(69 + 69 + 4 passed) andmise run check-distpass. The rebuild changed onlyactions/railway-redeploy/dist/index.js.Merge Danger
Door: two-way
A revert restores the old
src/anddist/.Blast Radius: small
Callers run
@main, so everyrailway-redeploystep picks this up on its next run. Only the failure path changes: the success path and every error raised after the inputs keep the same message, and a missing input still fails the step with exit 1, now with an annotation.Not in this PR:
core.getInputchecksrequiredbefore it trims, so a required input of only spaces passes as"", and the action goes on to fail at the Railway API ("Project not found") instead of naming the blank input.🤖 Generated with Claude Code
https://claude.ai/code/session_01ELZQC2WCLnTiM4Fd7nKdcE