Skip to content

fix(guard): parse gateway bypass query booleans#4926

Closed
NathanFlurry wants to merge 1 commit intosqlite-soak/vfs-staging-cache-ttlfrom
05-03-fix_guard_parse_gateway_bypass_query_booleans
Closed

fix(guard): parse gateway bypass query booleans#4926
NathanFlurry wants to merge 1 commit intosqlite-soak/vfs-staging-cache-ttlfrom
05-03-fix_guard_parse_gateway_bypass_query_booleans

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 May 4, 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.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 4, 2026

Code Review: fix(guard): parse gateway bypass query booleans

Overview

This PR fixes a bug where the bypass_connectable query parameter (passed as rvt-bypass_connectable=true) was being stored as a JSON string instead of a boolean, causing serde_json deserialization into RvtParams to fail since bypass_connectable: bool expects a JSON boolean.

The fix adds special-case parsing for bypass_connectable within extract_rvt_params and a small helper parse_query_bool.


What's Good

  • Focused and minimal. Only the affected field is changed; the rest of the query parsing is untouched.
  • parse_query_bool is clean and handles both "true"/"false" and "1"/"0" variants, which is standard for query param booleans.
  • The _ => arm in the match is a string comparison, not an enum — consistent with CLAUDE.md which permits _ for open value spaces.

Concerns

1. Silent fallback on invalid values produces a confusing error

When bypass_connectable=garbage is passed, parse_query_bool returns None and unwrap_or_else silently falls back to Value::String("garbage"). The subsequent serde_json::from_value call then emits something like "invalid type: string \"garbage\", expected a boolean" — which is not actionable for the caller.

A better path is to return an explicit error instead of falling back:

"bypass_connectable" => match parse_query_bool(value) {
    Some(b) => serde_json::Value::Bool(b),
    None => return Err(/* descriptive error about invalid boolean value */),
},

2. Maintenance risk: typed field list is split from the struct

RvtParams declares bypass_connectable: bool via serde, but the conversion logic lives separately in the match stripped { ... } block. If another typed field is added to RvtParams, it's easy to forget to update the match — there's no compile-time link between the two.

A more robust long-term approach would be to use #[serde(deserialize_with = "...")] on the specific fields, keeping the typing logic co-located with the struct definition. For the current size of RvtParams this is acceptable as-is, but worth noting as the struct grows.

3. No tests

There are no new tests covering:

  • bypass_connectable=true / false / 1 / 0 correctly parsed as booleans.
  • bypass_connectable=garbage producing an appropriate error.

Given this is a targeted bug fix for a specific parsing path, at minimum a unit test on extract_rvt_params (or the upstream parse_actor_path) would prevent regression.


Minor

  • parse_query_bool is clean, appropriately scoped as a private fn, and well-named.
  • No unnecessary comments added — consistent with project conventions.

Summary

The fix is correct and minimal. Two actionable items before merge: (1) handle invalid boolean values explicitly with a descriptive error instead of silently falling back to a string that produces an opaque serde error, and (2) add at least a unit test for the happy path and the invalid-value path.

@NathanFlurry NathanFlurry changed the base branch from sqlite-soak/sqlite-transport-trait to graphite-base/4926 May 4, 2026 04:13
@NathanFlurry NathanFlurry force-pushed the 05-03-fix_guard_parse_gateway_bypass_query_booleans branch from f7d89ed to 6b85d8c Compare May 4, 2026 05:14
@NathanFlurry NathanFlurry force-pushed the graphite-base/4926 branch from 48cc3bb to 17e8f52 Compare May 4, 2026 05:14
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4926 to sqlite-soak/vfs-staging-cache-ttl May 4, 2026 05:14
@NathanFlurry NathanFlurry mentioned this pull request May 4, 2026
11 tasks
@NathanFlurry NathanFlurry changed the base branch from sqlite-soak/vfs-staging-cache-ttl to graphite-base/4926 May 4, 2026 05:18
@NathanFlurry NathanFlurry changed the base branch from graphite-base/4926 to sqlite-soak/vfs-staging-cache-ttl May 4, 2026 08:06
@NathanFlurry NathanFlurry marked this pull request as ready for review May 4, 2026 08:06
@NathanFlurry NathanFlurry force-pushed the 05-03-fix_guard_parse_gateway_bypass_query_booleans branch from f8acbf0 to 0db4613 Compare May 4, 2026 09:06
@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