Skip to content

Fix Cause.Fail JSON error key#6469

Draft
coyaSONG wants to merge 1 commit into
Effect-TS:v3from
coyaSONG:fix/4683-cause-fail-json-key
Draft

Fix Cause.Fail JSON error key#6469
coyaSONG wants to merge 1 commit into
Effect-TS:v3from
coyaSONG:fix/4683-cause-fail-json-key

Conversation

@coyaSONG

@coyaSONG coyaSONG commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Cause.Fail exposes its recoverable error through the error property, but its toJSON and Node inspection output serialized the same value under failure. This aligns the serialized key with the public property and updates the direct and nested regression expectations.

The change includes a patch changeset and was validated with:

  • pnpm test packages/effect/test/Cause.test.ts
  • pnpm lint-fix
  • pnpm check
  • pnpm build
  • pnpm docgen

Implementation prepared with OpenAI Codex. No human code review has been performed.

Related

Summary by CodeRabbit

  • Bug Fixes

    • Updated Cause.Fail JSON serialization to use the error field, aligning it with the corresponding error property.
    • Updated serialized output for nested sequential and parallel causes to reflect the same field name.
  • Documentation

    • Added a patch release note documenting the JSON output alignment.

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 17, 2026
@changeset-bot

changeset-bot Bot commented Jul 17, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a582988

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
effect Patch

Not sure what this means? Click here to learn what changesets are.

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

@effect-bot effect-bot added 4.0 3.0 Used for issues, pull requests, etc. that are relevant for the `v3` branch targeting Effect v3. and removed 4.0 labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 712b75ea-bf72-4a3e-909c-cf6d0dc53d8d

📥 Commits

Reviewing files that changed from the base of the PR and between 7ccbd9c and a582988.

📒 Files selected for processing (3)
  • .changeset/align-cause-fail-json.md
  • packages/effect/src/internal/cause.ts
  • packages/effect/test/Cause.test.ts

📝 Walkthrough

Walkthrough

Cause.Fail JSON serialization now emits error instead of failure. Direct, sequential, and parallel cause expectations were updated, with a patch changeset documenting the alignment.

Changes

Cause.Fail JSON alignment

Layer / File(s) Summary
Serialization and validation
packages/effect/src/internal/cause.ts, packages/effect/test/Cause.test.ts, .changeset/align-cause-fail-json.md
The Fail JSON payload now uses error, and tests cover direct, sequential, and parallel causes with the updated field name. A patch changeset records the change.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested labels: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing the Cause.Fail JSON key from failure to error.
Linked Issues check ✅ Passed The change aligns Cause.Fail serialization with the instance shape by emitting error and updating regression tests.
Out of Scope Changes check ✅ Passed The changeset and test updates directly support the Cause.Fail JSON fix and do not introduce unrelated scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

@coderabbitai coderabbitai Bot added the bug Something isn't working label Jul 18, 2026
@mikearnaldi

Copy link
Copy Markdown
Member

@coderabbitai investigate the CI failures

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="Effect-TS/effect"
pr="6469"

echo "=== Pull request and check rollup ==="
gh pr view "$pr" --repo "$repo" \
  --json url,headRefName,headRefOid,statusCheckRollup \
  --jq '{url, headRefName, headRefOid, checks: [.statusCheckRollup[] | {name, status, conclusion, detailsUrl, workflowName: .workflowName}]}'

echo
echo "=== Workflow runs for this PR ==="
gh run list --repo "$repo" --pr "$pr" --limit 100 \
  --json databaseId,name,status,conclusion,event,headSha,url,createdAt,updatedAt \
  --jq '.[] | select(.conclusion == "failure" or .status != "completed")'

echo
echo "=== Failed job details and available log excerpts ==="
while IFS= read -r run_id; do
  [ -z "$run_id" ] && continue
  echo "--- Run $run_id ---"
  gh run view "$run_id" --repo "$repo" \
    --json url,name,status,conclusion,jobs \
    --jq '{url,name,status,conclusion,jobs: [.jobs[] | select(.conclusion == "failure") | {name,conclusion,startedAt,completedAt,steps: [.steps[] | select(.conclusion == "failure") | {name,number,conclusion}]}]}'
  echo "--- Failed-step log output for run $run_id ---"
  gh run view "$run_id" --repo "$repo" --log-failed 2>&1 || true
done < <(gh run list --repo "$repo" --pr "$pr" --limit 100 --json databaseId,conclusion --jq '.[] | select(.conclusion == "failure") | .databaseId')

Length of output: 4680


🏁 Script executed:

#!/bin/bash
set -euo pipefail

repo="Effect-TS/effect"
run_id="29595130308"
job_id="88064176955"

echo "=== Workflow run metadata ==="
gh api "repos/$repo/actions/runs/$run_id" \
  --jq '{html_url, head_sha, head_branch, event, status, conclusion, created_at, updated_at}'

echo
echo "=== Failed job metadata ==="
gh api "repos/$repo/actions/jobs/$job_id" \
  --jq '{html_url, name, status, conclusion, started_at, completed_at, steps: [.steps[] | {number, name, status, conclusion}]}'

echo
echo "=== Failed-step logs ==="
gh run view "$run_id" --repo "$repo" --log-failed 2>&1 || true

echo
echo "=== Context around failure markers in complete job log ==="
tmp_log="$(mktemp)"
trap 'rm -f "$tmp_log"' EXIT
gh api "repos/$repo/actions/jobs/$job_id/logs" > "$tmp_log"
rg -n -i -C 12 \
  '(fail(?:ed|ure)?|error|assert(?:ion)?|expected|received|exit code|test summary)' \
  "$tmp_log" || true

Length of output: 123956


@mikearnaldi, the failure is a PR-related stale expectation, not CI infrastructure.

  • Only Test (Node 2/4) failed; Types, Lint, Build, Snapshot, and the other three Node shards passed.
  • packages/effect/test/Cause.test.ts passes.
  • packages/effect/test/Exit.test.ts still expects nested Cause.Fail JSON to contain:
    { failure: "failure" }
    but the updated serializer correctly produces:
    { error: "failure" }

The two failing assertions are:

  • Exit > toJSON > fail — Line 16
  • Exit > toString > fail — Line 53

Update both expected serialized cause objects/strings in packages/effect/test/Exit.test.ts from failure to error. This will align the transitive Exit.fail(...) coverage with the intended Cause.Fail serialization change.

@mikearnaldi

Copy link
Copy Markdown
Member

@coderabbitai fix the tests

@mikearnaldi

Copy link
Copy Markdown
Member

@coderabbitai create a commit fixing the test issues

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Exit test structure ==="
ast-grep outline packages/effect/test/Exit.test.ts --items all

echo
echo "=== Cause.Fail serialization expectations in Exit tests ==="
rg -n -C 8 'failure|error|toJSON|toString' packages/effect/test/Exit.test.ts

echo
echo "=== Available test scripts ==="
if [ -f package.json ]; then
  jq '{scripts}' package.json
fi
if [ -f packages/effect/package.json ]; then
  jq '{scripts}' packages/effect/package.json
fi

Length of output: 4397


@mikearnaldi Confirmed: there are four stale expectations in packages/effect/test/Exit.test.ts—two object assertions and two string assertions. I can’t create commits directly, but this is ready for the code-change workflow.

  • Replace every nested Cause.Fail serialized failure key in Exit.test.ts with error.
  • Run focused Exit and Cause tests.
  • Commit the test-only fix with a clear message.

  • ❌ Failed to create commit - (🔄 Check again to retry)

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

❌ Failed to create commit: AGENT_CHAT: Failed to create commit

1 similar comment
@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

❌ Failed to create commit: AGENT_CHAT: Failed to create commit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.0 Used for issues, pull requests, etc. that are relevant for the `v3` branch targeting Effect v3. bug Something isn't working

Projects

Status: Discussion Ongoing

Development

Successfully merging this pull request may close these issues.

3 participants