Conversation
…redundant `parse_key_value_pairs` handling This PR introduces a `parse_text_to_object` helper function to reduce code duplication and consolidate common operations, which was previously scattered across: - `native_parse_query_string` - `native_parse_cookies` - `native_parse_form_urlencoded` It also adds an `expect_object` extraction function to `src/stdlib/helpers.rs` to keep extraction methods consistent in the interpreter layer. Co-authored-by: logbie <1138960+logbie@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR adds a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
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 docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR refactors the stdlib text parsing builtins to reduce duplicated argument/type extraction and parsing boilerplate, and extends the stdlib helper “expect_*” extractors for object values.
Changes:
- Introduces a shared
parse_text_to_objecthelper to consolidateparse_query_string,parse_cookies, andparse_form_urlencodedimplementations. - Updates the three parsing builtins to delegate to the new helper (including optional prefix trimming for query strings).
- Adds
expect_objectvia thegenerate_expect!macro for consistentValueextraction patterns.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/stdlib/text.rs |
Refactors query/cookie/form parsing builtins to use a unified parsing helper. |
src/stdlib/helpers.rs |
Adds expect_object extractor generated by generate_expect!. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn parse_text_to_object( | ||
| name: &str, | ||
| args: Vec<Value>, | ||
| delimiter: char, | ||
| trim_parts: bool, |
There was a problem hiding this comment.
The refactor changes the parsing implementation for parse_query_string, parse_cookies, and parse_form_urlencoded, but there don’t appear to be any integration tests covering these builtins (including edge cases like leading '?', whitespace around cookie separators, valueless pairs, and percent-decoding). Adding tests would help prevent regressions in the shared parse_text_to_object helper.
Summary of Changes
native_parse_query_string,native_parse_cookies, andnative_parse_form_urlencodedfunctions withinsrc/stdlib/text.rshad duplicated boilerplate code for checking arguments, extracting text fromValue, and wrapping the parsed results back into aValue::Object.expect_texterror flows and formatting quirks.parse_text_to_objectthat abstracts away the repetitive parameter extraction, optional prefix trimming, key-value parsing, and object generation. Furthermore, addedexpect_objectusing thegenerate_expect!macro insrc/stdlib/helpers.rsfor consistency with existing interpreter data types extraction logic (expect_list,expect_text).Verification Checklist
cargo fmtexecuted and passed.cargo clippyreturned no warnings or errors.cargo testsuites passed (100% success rate).PR created automatically by Jules for task 3724693184136274828 started by @logbie
Summary by CodeRabbit
New Features
expect_objectfunction to validate and extract object values with detailed error reporting for type mismatches.Refactor