Skip to content

fix: restore inputs from state in post#255

Merged
zkochan merged 1 commit into
pnpm:masterfrom
haines:fix-inputs
May 11, 2026
Merged

fix: restore inputs from state in post#255
zkochan merged 1 commit into
pnpm:masterfrom
haines:fix-inputs

Conversation

@haines

@haines haines commented May 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #253

Summary by CodeRabbit

  • Refactor
    • Improved the action's internal lifecycle management with better separation of main and post step execution flows, enhancing state management for more reliable pnpm setup and caching operations.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

The action entrypoint is refactored to use GitHub Action state (saveState/getState) to persist inputs between the main and post-cleanup steps, fixing issues when the action runs via a composite action. The dispatcher routes based on stored state instead of function arguments, runMain() derives and saves inputs, and runPost() reconstructs them for cleanup.

Changes

State-based input persistence for GitHub Action post step

Layer / File(s) Summary
Main dispatcher routing
src/index.ts
main() now invokes runPost() or runMain() without arguments, using getState('is_post') to determine which path to execute.
Main step with input persistence
src/index.ts
runMain() takes no parameters; it creates inputs via getInputs(), persists them to action state with saveState('inputs', JSON.stringify(inputs)), sets is_post to 'true', then runs the install sequence and cache restore.
Post step with input reconstruction
src/index.ts
New runPost() function reconstructs inputs from persisted action state via JSON.parse(getState('inputs')), then executes pruneStore(inputs) and saveCache(inputs) for cleanup.

🎯 2 (Simple) | ⏱️ ~8 minutes

🐰 A rabbit hops through the state, storing inputs for later fate,
No more mixed-up args in the post-action stage,
With saveState and getState upon the page,
Composite actions now work great!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and concisely describes the main change: restoring inputs from state in the post step, which directly addresses the core fix for issue #253.
Linked Issues check ✅ Passed The PR implementation directly addresses the root causes identified in issue #253: inputs are now persisted via saveState() in main and restored from STATE in post, fixing the composite-action input-loss issue.
Out of Scope Changes check ✅ Passed All changes in src/index.ts are scoped to refactoring the control flow to persist and restore inputs via GitHub Action state, which is directly required by issue #253.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/index.ts`:
- Line 34: The code unconditionally calls JSON.parse(getState('inputs')) when
assigning const inputs in src/index.ts, which can throw if getState('inputs') is
missing/empty/corrupted; wrap the retrieval and parse in a safe guard: read
const raw = getState('inputs'), check raw is truthy before parsing, and/or parse
inside a try/catch that falls back to a safe default (e.g., undefined or an
empty Inputs-like object) and logs the parse error, so the post-cleanup path
(and the rest of the process) cannot be interrupted by JSON.parse; update the
assignment of inputs accordingly to use the guarded value.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 86c3a3df-8941-4d0f-80fb-43dd0041dfb5

📥 Commits

Reviewing files that changed from the base of the PR and between 1155470 and 496058d.

⛔ Files ignored due to path filters (1)
  • dist/index.js is excluded by !**/dist/**
📒 Files selected for processing (1)
  • src/index.ts
📜 Review details
🔇 Additional comments (2)
src/index.ts (2)

11-15: Good post/main dispatch split.

Using getState('is_post') to route between phases is clear and matches the intended GitHub Action lifecycle fix.


18-21: Good: inputs are persisted before main work starts.

Saving inputs up front reduces drift risk between main and post, especially for composite-action invocations.

Comment thread src/index.ts
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.

Errors in post-install when called via composite action

2 participants