Skip to content

Conversation

@gwbischof
Copy link
Contributor

@gwbischof gwbischof commented Jul 1, 2025

  • Changes /close/{node_id} to a DELETE and made idempotent.
  • Closing the connection marks `seq_num:{node_id} for expiration.
  • Deny the websocket connection if seq_num:{node_id} doesn't exist.
  • Add a check of content-length header to let clients know that their data is too large.

Notes on denying websocket connections: https://www.starlette.io/websockets/#send-denial-response

I think we squash-merge this one, the commits aren't interesting. I was experimenting with using AI to write tests to find bugs in the server code. I ended up removing most of the AI tests, they mostly verified that things were working correctly, and pointed out a couple minor issues.

gwbischof added 21 commits July 1, 2025 17:16
…gaps

Learned: Focusing on lightweight edge cases revealed actual crashes better than resource-intensive stress tests.
… server vulnerabilities

Learned: Using pytest.mark.timeout prevented hanging tests and allowed systematic testing of edge cases.
…nt indefinite blocking

Learned: Selective timeout application only on hanging tests maintains test efficiency while ensuring robust execution.
…ging behavior

Learned: TODOs should focus on actionable bugs rather than design choices to maintain clear development priorities.
…uding crashes, hangs, and race conditions

Learned: Removing validation tests and focusing only on tests that expose real bugs creates a more valuable test suite than broadly testing edge cases.
…suite from 12 to 20 comprehensive tests that all fail when server has bugs

Learned: Moving imports to module level and removing defensive exception handling makes tests more maintainable and clearly exposes server issues.
…t suite on 18 actual bugs requiring fixes

Learned: Keeping only failing tests that expose real bugs makes the test suite more actionable and prevents confusion about what needs to be fixed.
…tionality and expected fixes.

Learned: Merging tests by server code path and creating separate files by functional area makes test suite more maintainable than one large file.
…oint that returns proper 400 responses.

Learned: Testing failure first, then implementing the fix, then verifying success creates a clear development cycle that ensures the fix actually works.
… attacks with 16MB payload, 8KB header, and 1MB WebSocket frame limits.

Learned: Adding size limits early in the request pipeline prevents resource exhaustion while maintaining performance for legitimate requests.
…n real client-accessible bugs only.

Learned: Tests should only validate scenarios that clients can actually trigger through public APIs rather than artificial edge cases requiring direct database access.
…een bugs and their solutions.

Learned: Linking fixes directly to the tests that expose the bugs improves code maintainability and helps future developers understand the purpose of each fix.
…r 400 responses while letting server errors bubble up as 500.

Learned: Catching overly broad exception types can mask serious server issues and mislead users about the actual cause of errors.
…s and improve user experience with clear, actionable error descriptions.

Learned: Raw exception details should never be exposed to clients as they leak implementation details and provide potential attack surface information.
…elopment principles and eliminate dead code.

Learned: Only implement code that has corresponding tests to ensure functionality is validated and maintainable.
… crashes

Summary: Server now validates request sizes and handles malformed JSON gracefully with proper HTTP error responses instead of crashing.

Learned: Middleware-level validation was unnecessary overhead - endpoint-specific validation is more targeted and easier to test consistently.
@gwbischof gwbischof marked this pull request as ready for review July 7, 2025 21:37
gwbischof added 3 commits July 8, 2025 12:26
Summary: The /close endpoint now uses a Pydantic model for automatic JSON parsing and validation instead of manual error handling.

Learned: Pydantic models eliminate boilerplate error handling code and provide better type safety than manual JSON parsing.
@gwbischof gwbischof requested a review from danielballan July 8, 2025 16:41
@gwbischof gwbischof requested a review from danielballan July 11, 2025 16:57
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.

3 participants