Skip to content

fix(railway-redeploy): report missing inputs through setFailed - #15

Merged
rqbazan merged 1 commit into
mainfrom
fix/railway-redeploy-input-errors
Oct 18, 2026
Merged

rqbazan merged 1 commit into
mainfrom
fix/railway-redeploy-input-errors

Conversation

@rqbazan

@rqbazan rqbazan commented Oct 18, 2026

Copy link
Copy Markdown
Member

Summary

main() read its required inputs before its try, and the entry point called main() with no .catch. A missing input threw from core.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 through core.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.ts diff is mostly the dedent of the old try body: git diff -w shows the real change. The action also gets its first unit test (src/index.test.ts) and the test task in its mise.toml, so mise run test, the pre-push hook and CI pick it up. dist/ is rebuilt with mise run check-dist.

Evidence

  • Before: node dist/index.js without INPUT_PROJECT_ID prints the whole minified dist/index.js line (~115 KB of log) and a stack trace, exit 1, no annotation:

    file:///.../railway-redeploy/dist/index.js:3
    /*! ws. MIT License. ... */ ...115 KB of minified code...
    Error: Input required and not supplied: project_id
        at main (file:///.../dist/index.js:3:112204)
        ...
    Node.js v24.21.0
    

    After:

    ::error::🚨 Failed to redeploy railway service: Input required and not supplied: project_id
    exit=1
    
  • 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 old src/index.ts: 4 failed. With the fix: 4 passed.

    run entry point with INPUT_* minus <name>
      expect status == 1
      expect stdout has "::error::🚨 Failed to redeploy railway service: Input required and not supplied: <name>"
    
  • mise run check, mise run test (69 + 69 + 4 passed) and mise run check-dist pass. The rebuild changed only actions/railway-redeploy/dist/index.js.

Merge Danger

Door: two-way

A revert restores the old src/ and dist/.

Blast Radius: small

Callers run @main, so every railway-redeploy step 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.getInput checks required before 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

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
@changeset-bot

changeset-bot Bot commented Oct 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: dcb06de

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@rqbazan
rqbazan merged commit 553f8dd into main Oct 18, 2026
5 checks passed
@rqbazan
rqbazan deleted the fix/railway-redeploy-input-errors branch October 18, 2026 15:59
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.

1 participant