Normalize cookie flag semantics#6
Conversation
BREAKING CHANGE: httpOnly, secure, and partitioned are now two-state flags with false defaults.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
📝 WalkthroughWalkthroughConverted Cookie flag fields (httpOnly, secure, partitioned) from nullable to non-nullable booleans with default false; removed corresponding enum entries; updated parsing, validation, serialization, equality, and tests; added docs describing flag semantics and parsing behavior. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
test/from_string_test.dart (1)
82-90: Please lock down the=falseform too.Lines 82-90 already establish that non-standard values like
1andtruestill enable the flag. With the new two-state wording,Secure=false,HttpOnly=false, andPartitioned=falseare the inputs most likely to surprise users, so I'd add that case here as well to keep the wire-format contract unambiguous.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/from_string_test.dart` around lines 82 - 90, Add assertions to the existing test "should treat valueless flags with non-standard values as enabled" (which calls Cookie.fromString) to also verify that explicit "=false" disables the flags; specifically, parse a cookie string like 'sid=abc; Secure=false; HttpOnly=false; Partitioned=false' using Cookie.fromString and assert that cookie.secure, cookie.httpOnly, and cookie.partitioned are all false so the parser treats the "=false" form as the disabled state.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@CHANGELOG.md`:
- Around line 3-4: Update the changelog entry to explicitly document the
breaking API change: state that the properties CookieNullableField.httpOnly,
CookieNullableField.secure, and CookieNullableField.partitioned have been
removed (compile-time break) and describe the migration path (e.g., replace
usages with the new two-state flags on Cookie or set explicit false/omitted
semantics accordingly), so consumers know how to update their code; ensure the
wording appears near the existing lines about flag semantics to make the
relationship clear.
---
Nitpick comments:
In `@test/from_string_test.dart`:
- Around line 82-90: Add assertions to the existing test "should treat valueless
flags with non-standard values as enabled" (which calls Cookie.fromString) to
also verify that explicit "=false" disables the flags; specifically, parse a
cookie string like 'sid=abc; Secure=false; HttpOnly=false; Partitioned=false'
using Cookie.fromString and assert that cookie.secure, cookie.httpOnly, and
cookie.partitioned are all false so the parser treats the "=false" form as the
disabled state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e7255ab4-a441-4165-abc1-01ea697f92b0
📒 Files selected for processing (5)
CHANGELOG.mdREADME.mdlib/src/cookie.darttest/copy_with_test.darttest/from_string_test.dart
| - make `httpOnly`, `secure`, and `partitioned` two-state flags with `false` defaults | ||
| - treat omitted flags and explicit `false` as the same value semantics |
There was a problem hiding this comment.
Document the clear API break explicitly.
Lines 3-4 describe the semantic shift, but the compile-time break most consumers will hit is that CookieNullableField.httpOnly, CookieNullableField.secure, and CookieNullableField.partitioned are gone. Please call that out here so the migration path is discoverable from the release notes.
✏️ Suggested changelog wording
-- make `httpOnly`, `secure`, and `partitioned` two-state flags with `false` defaults
-- treat omitted flags and explicit `false` as the same value semantics
+- BREAKING: make `httpOnly`, `secure`, and `partitioned` two-state flags with `false` defaults
+- BREAKING: treat omitted flags and explicit `false` as the same value semantics
+- BREAKING: remove `CookieNullableField.httpOnly`, `CookieNullableField.secure`, and
+ `CookieNullableField.partitioned`; `copyWith(clear: ...)` can no longer clear those flags🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@CHANGELOG.md` around lines 3 - 4, Update the changelog entry to explicitly
document the breaking API change: state that the properties
CookieNullableField.httpOnly, CookieNullableField.secure, and
CookieNullableField.partitioned have been removed (compile-time break) and
describe the migration path (e.g., replace usages with the new two-state flags
on Cookie or set explicit false/omitted semantics accordingly), so consumers
know how to update their code; ensure the wording appears near the existing
lines about flag semantics to make the relationship clear.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/from_string_test.dart (1)
82-96: Consider adding test coverage for0and?0flag values.The test covers
1,true,?1, andfalse, butparseFlagValuealso handles0and?0as false. Adding these cases would improve coverage.🧪 Suggested additional test case
final disabledCookie = Cookie.fromString( 'sid=abc; Secure=false; HttpOnly=false; Partitioned=false', ); + final disabledCookieAlt = Cookie.fromString( + 'sid=abc; Secure=0; HttpOnly=?0; Partitioned=0', + ); expect(enabledCookie.secure, isTrue); expect(enabledCookie.httpOnly, isTrue); expect(enabledCookie.partitioned, isTrue); expect(disabledCookie.secure, isFalse); expect(disabledCookie.httpOnly, isFalse); expect(disabledCookie.partitioned, isFalse); + expect(disabledCookieAlt.secure, isFalse); + expect(disabledCookieAlt.httpOnly, isFalse); + expect(disabledCookieAlt.partitioned, isFalse);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/from_string_test.dart` around lines 82 - 96, Add assertions to the existing test 'should treat non-standard flag values predictably' to cover the missing false-equivalent flag strings "0" and "?0": create Cookie.fromString instances (e.g., a cookie with Secure=0; HttpOnly=?0; Partitioned=0 and another mixing those forms) and assert their secure, httpOnly, and partitioned properties are false so parseFlagValue's handling of "0" and "?0" is validated; update the test around the existing enabledCookie/disabledCookie cases (referencing Cookie.fromString and the properties secure, httpOnly, partitioned) to include these additional negative cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/from_string_test.dart`:
- Around line 82-96: Add assertions to the existing test 'should treat
non-standard flag values predictably' to cover the missing false-equivalent flag
strings "0" and "?0": create Cookie.fromString instances (e.g., a cookie with
Secure=0; HttpOnly=?0; Partitioned=0 and another mixing those forms) and assert
their secure, httpOnly, and partitioned properties are false so parseFlagValue's
handling of "0" and "?0" is validated; update the test around the existing
enabledCookie/disabledCookie cases (referencing Cookie.fromString and the
properties secure, httpOnly, partitioned) to include these additional negative
cases.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: d4d4eb8f-f145-4803-a1eb-74f41aa7896d
📒 Files selected for processing (3)
CHANGELOG.mdlib/src/cookie.darttest/from_string_test.dart
Summary by CodeRabbit
Documentation
Refactor
Tests