Skip to content

docs: require close-code rejection for websocket auth/policy failures#4727

Closed
NathanFlurry wants to merge 1 commit into04-23-fix_rivetkit_inspector_reports_actual_config_state_real_queue_messagesfrom
04-23-docs_require_close-code_rejection_for_websocket_auth_policy_failures
Closed

docs: require close-code rejection for websocket auth/policy failures#4727
NathanFlurry wants to merge 1 commit into04-23-fix_rivetkit_inspector_reports_actual_config_state_real_queue_messagesfrom
04-23-docs_require_close-code_rejection_for_websocket_auth_policy_failures

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 24, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown
Contributor

Preview packages published to npm

Install with:

npm install rivetkit@pr-4727

All packages published as 0.0.0-pr.4727.e649173 with tag pr-4727.

Engine binary is shipped via @rivetkit/engine-cli on linux-x64-musl, linux-arm64-musl, darwin-x64, and darwin-arm64. Windows users should use the release installer or set RIVET_ENGINE_BINARY.

Docker images:

docker pull rivetdev/engine:slim-e649173
docker pull rivetdev/engine:full-e649173
Individual packages
npm install rivetkit@pr-4727
npm install @rivetkit/react@pr-4727
npm install @rivetkit/rivetkit-napi@pr-4727
npm install @rivetkit/workflow-engine@pr-4727

@claude
Copy link
Copy Markdown

claude Bot commented Apr 24, 2026

PR Review: docs: require close-code rejection for websocket auth/policy failures

Summary

The guidance is technically correct — browsers only see CloseEvent.code / .reason on a failed WebSocket upgrade, never the HTTP status, so pre-upgrade HTTP rejections are opaque to browser clients. The close code 1008 choice and inspector.unauthorized convention also match the existing inspector_ws.rs implementation.

That said, there are a few issues worth addressing:


Issues

1. CLAUDE.md format violation (blocker)

CLAUDE.md itself states:

"When adding entries to any CLAUDE.md file, keep them concise. Ideally a single bullet point or minimal bullet points. Do not write paragraphs."
"When the user asks to update any CLAUDE.md, add one-line bullet points only."

The added entry is a multi-sentence paragraph. It should be split into concise one-line bullets. Suggested rewrite:

## WebSocket Rejection

- Reject WebSocket connections by accepting the upgrade and sending a close frame; never reject with an HTTP status before upgrade — browsers see only `CloseEvent.code` / `.reason`, not the HTTP status of a failed upgrade.
- Use close code `1008` (policy violation) for auth/policy failures, with a `<group>.<code>` reason string (e.g. `inspector.unauthorized`).
- Use close code `1011` for unexpected internal errors.

2. Scope ambiguity: "any rejection reason" vs. only auth failures

The bullet prescribes <group>.<code> format for "any rejection reason" up front, then narrows to auth failures at the end. The codebase uses different close codes for different error kinds (1008 for policy, 1011 for internal errors, 1003 for unsupported data). The rule should either specify the full mapping or limit itself to the auth case where the convention is established.


3. Section placement

The new section sits between "Trust Boundaries" and "Fail-By-Default Runtime". Consider moving it under "Error Handling" or appending it to "Trust Boundaries", since WebSocket rejection is primarily an auth + trust-boundary concern.


Verdict

The intent and technical rationale are solid. This just needs to be reformatted as concise bullets (per CLAUDE.md conventions) and have the close-code mapping clarified before merging.

@NathanFlurry NathanFlurry force-pushed the 04-23-docs_require_close-code_rejection_for_websocket_auth_policy_failures branch from 6ac729a to c02368f Compare April 24, 2026 09:52
@NathanFlurry NathanFlurry force-pushed the 04-23-fix_rivetkit_inspector_reports_actual_config_state_real_queue_messages branch from 30e8ba6 to ad4d92a Compare April 24, 2026 09:52
@NathanFlurry NathanFlurry mentioned this pull request Apr 24, 2026
11 tasks
@NathanFlurry NathanFlurry force-pushed the 04-23-fix_rivetkit_inspector_reports_actual_config_state_real_queue_messages branch from ad4d92a to be354a6 Compare April 24, 2026 10:19
@NathanFlurry NathanFlurry force-pushed the 04-23-docs_require_close-code_rejection_for_websocket_auth_policy_failures branch from c02368f to a7011b4 Compare April 24, 2026 10:19
@NathanFlurry NathanFlurry force-pushed the 04-23-docs_require_close-code_rejection_for_websocket_auth_policy_failures branch from a7011b4 to 84c1d02 Compare April 24, 2026 10:32
@NathanFlurry NathanFlurry force-pushed the 04-23-fix_rivetkit_inspector_reports_actual_config_state_real_queue_messages branch from be354a6 to 5b61e8e Compare April 24, 2026 10:32
@NathanFlurry NathanFlurry force-pushed the 04-23-docs_require_close-code_rejection_for_websocket_auth_policy_failures branch from 84c1d02 to d4cb14c Compare April 24, 2026 11:48
@NathanFlurry NathanFlurry force-pushed the 04-23-fix_rivetkit_inspector_reports_actual_config_state_real_queue_messages branch from 5b61e8e to d1095c3 Compare April 24, 2026 11:48
@NathanFlurry NathanFlurry force-pushed the 04-23-docs_require_close-code_rejection_for_websocket_auth_policy_failures branch from d4cb14c to c4e501a Compare April 24, 2026 12:14
@NathanFlurry NathanFlurry force-pushed the 04-23-fix_rivetkit_inspector_reports_actual_config_state_real_queue_messages branch from 8a4bc0d to a96fbd9 Compare April 24, 2026 12:32
@NathanFlurry NathanFlurry force-pushed the 04-23-docs_require_close-code_rejection_for_websocket_auth_policy_failures branch from c4e501a to 6b10ba8 Compare April 24, 2026 12:32
@NathanFlurry
Copy link
Copy Markdown
Member Author

Landed in main via stack-merge fast-forward push. Commits are in main; closing to match.

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