Skip to content

🐛 Fix jsonl format ignoring -@ and -e flags#2588

Merged
ChanTsune merged 1 commit into
mainfrom
cli/list/jsonl-conditional-fields
Jan 18, 2026
Merged

🐛 Fix jsonl format ignoring -@ and -e flags#2588
ChanTsune merged 1 commit into
mainfrom
cli/list/jsonl-conditional-fields

Conversation

@ChanTsune
Copy link
Copy Markdown
Owner

@ChanTsune ChanTsune commented Jan 9, 2026

The jsonl format was always outputting acl and xattr fields as empty arrays regardless of whether -e (acl) or -@ (xattr) flags were specified. This was inconsistent with the fflags field behavior.

Now these fields use skip_serializing_if to omit them entirely when not requested, matching the expected behavior.

Summary by CodeRabbit

  • New Features

    • JSON/JSONL output from the list command now omits ACL and extended attribute fields by default; they are included only when explicitly requested.
  • Bug Fixes

    • Empty metadata fields in JSONL (e.g., accessed) normalized to an empty string for consistent output.
  • Tests

    • Added tests verifying ACL and XAttr are included when requested and updated expectations for default JSON/JSONL outputs.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 9, 2026

📝 Walkthrough

Walkthrough

Make FileInfo's acl and xattr optional and serialize them only when corresponding display flags are enabled; update JSONL construction to conditionally include acl, xattr, and fflags. Tests updated to reflect omitted fields by default and new flag-driven expectations.

Changes

Cohort / File(s) Summary
Core Implementation
cli/src/command/list.rs
FileInfo<'a>: acl and xattr changed from Vec to Option<Vec> with #[serde(skip_serializing_if = "Option::is_none")]. json_line_entries_to now computes show_acl/show_xattr and conditionally populates acl, xattr, and fflags.
Tests — JSONL expectations
cli/tests/cli/list/option_format_jsonl.rs, cli/tests/cli/list/option_show_fflags.rs
Updated expected JSONL outputs to omit empty acl/xattr and adjusted accessed values. Added tests asserting acl included when -e --unstable is used and xattr included when -@ is used.

Sequence Diagram(s)

(Skipped — changes are localized to CLI data serialization and test expectations and do not introduce a multi-component sequential flow requiring visualization.)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I nibble through fields with tidy paws,
Optional crumbs left where nothing was,
ACLs and xattrs only when you ask,
JSONL lighter, tidy and fast,
Hooray — a neat output for every task. 🐇

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the specific bug fix: conditional output of acl and xattr fields in jsonl format based on the -@ and -e flags.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8e987d and 91f6da3.

📒 Files selected for processing (3)
  • cli/src/command/list.rs
  • cli/tests/cli/list/option_format_jsonl.rs
  • cli/tests/cli/list/option_show_fflags.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: plan
  • GitHub Check: tier1 (macos-latest, stable)
  • GitHub Check: tier1 (windows-11-arm, nightly)
  • GitHub Check: tier1 (windows-11-arm, stable)
🔇 Additional comments (8)
cli/src/command/list.rs (3)

1126-1129: LGTM! Excellent use of Option types for conditional serialization.

The change from Vec<AclEntry> and Vec<XAttr<'a>> to Option<Vec<...>> with skip_serializing_if is exactly the right approach to conditionally omit these fields from JSON output when not requested. This aligns perfectly with the existing fflags field pattern.


1150-1151: LGTM! Clean flag derivation.

Extracting show_acl and show_xattr from options upfront keeps the subsequent mapping logic clean and consistent with the show_fflags pattern.


1187-1205: LGTM! Conditional population correctly implements the fix.

The logic properly populates acl and xattr fields only when their respective flags are enabled:

  • Uses show_acl.then(|| ...) to conditionally construct ACL entries from the iterator
  • Uses show_xattr.then(|| ...) to conditionally construct XAttr entries with base64-encoded values
  • Returns None when flags are disabled, triggering skip_serializing_if to omit the fields

This directly addresses the bug where these fields were always output as empty arrays regardless of flag presence.

cli/tests/cli/list/option_show_fflags.rs (2)

108-115: LGTM! Test correctly validates conditional field inclusion.

The updated expectations properly reflect that with the -O flag, only fflags is included in the JSON output, while acl and xattr are omitted (since their respective flags weren't provided). This validates the fix for the reported bug.


139-146: LGTM! Test correctly validates default omission.

Without any flags (-O, -e, -@), all three optional fields are correctly omitted from the JSON output. This confirms the conditional serialization is working as expected.

cli/tests/cli/list/option_format_jsonl.rs (3)

25-42: LGTM! Test expectations correctly updated for conditional field omission.

The updated JSON expectations properly exclude acl and xattr fields when their corresponding flags (-e and -@) are not provided, aligning with the fix for the reported bug.


198-230: LGTM! Excellent test coverage for ACL inclusion.

This new test validates the positive case: when the -e flag is provided, the acl field is correctly included in the JSON output with the expected structure (platform and entries). This ensures the fix works bidirectionally—omitting when not requested and including when requested.


232-272: LGTM! Comprehensive test coverage for xattr inclusion.

This new test validates that with the -@ flag, the xattr field is correctly included in JSON output. The test also properly verifies:

  • Files without xattrs show "xattr":[] (line 253)
  • Files with xattrs show the key and base64-encoded value (line 265)

This ensures the fix correctly handles both populated and empty xattr scenarios.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @ChanTsune, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses an inconsistency in the jsonl output format where acl and xattr fields were always present as empty arrays, even when their corresponding flags were not provided. The changes modify the serialization logic to omit these fields entirely from the JSON output unless they are explicitly requested, resulting in cleaner and more accurate data representation.

Highlights

  • JSONL Output Consistency: Ensured that acl and xattr fields are only included in jsonl output when explicitly requested via their respective command-line flags (-e and -@).
  • Serialization Logic: Standardized the serialization behavior of acl and xattr fields to match the existing fflags field, using #[serde(skip_serializing_if = "Option::is_none")] and conditional Option construction.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes a bug where acl and xattr fields were always present in the jsonl output, even when not requested. By making these fields optional and using serde(skip_serializing_if = "Option::is_none"), their behavior is now consistent with the fflags field, and they are only included in the output when the corresponding -e or -@ flags are used. The implementation is clean and idiomatic, and the existing tests have been updated to reflect the corrected output. I've added one suggestion to improve test coverage for the new behavior.

Comment thread cli/tests/cli/list/option_format_jsonl.rs
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cli/tests/cli/list/option_format_jsonl.rs (1)

176-195: LGTM! Encrypted archive test updated correctly.

The test expectations are updated consistently. Note that the provided tests validate that acl and xattr are omitted when flags are not used, but there don't appear to be tests in this file that verify these fields ARE included when -@ or -e flags are provided.

Consider adding positive test cases to verify that acl and xattr fields appear in the JSON output when -@ and -e flags are provided, respectively.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0368929 and 95b845c.

📒 Files selected for processing (3)
  • cli/src/command/list.rs
  • cli/tests/cli/list/option_format_jsonl.rs
  • cli/tests/cli/list/option_show_fflags.rs
🔇 Additional comments (9)
cli/tests/cli/list/option_format_jsonl.rs (4)

24-43: LGTM! Test expectations correctly updated.

The expected JSON output now correctly omits acl and xattr fields when the -@ and -e flags are not provided, consistent with the PR objective.


67-86: LGTM! Solid archive test updated correctly.

The test expectations properly validate that acl and xattr fields are omitted from solid archive listings when flags are not provided.


111-116: LGTM! Filtered listing test updated correctly.


144-151: LGTM! Directory filter test updated correctly.

cli/tests/cli/list/option_show_fflags.rs (2)

107-116: LGTM! Conditional field inclusion working correctly.

The test correctly validates that fflags is included when -O is provided, while acl and xattr are omitted when -e and -@ are not provided, demonstrating the proper conditional serialization behavior.


138-147: LGTM! All conditional fields correctly omitted.

The test properly validates that when none of the optional flags (-O, -@, -e) are provided, all corresponding fields (fflags, acl, xattr) are omitted from the JSON output.

cli/src/command/list.rs (3)

1124-1129: LGTM! Struct fields correctly updated for conditional serialization.

The acl and xattr fields are properly changed to Option types with skip_serializing_if = "Option::is_none", following the same pattern as the existing fflags field. This enables clean omission of these fields from JSON output when not requested.


1149-1151: LGTM! Flag variables properly initialized.

The show_acl and show_xattr flags are correctly extracted from options for use within the parallel iterator closure, following the same pattern as the existing show_fflags.


1187-1205: LGTM! Conditional field population implemented correctly.

The logic properly uses show_fflags.then(), show_acl.then(), and show_xattr.then() to conditionally populate the optional fields. When a flag is false, then() returns None, which combined with skip_serializing_if causes the field to be omitted from the JSON output. The transformation logic for ACL and xattr data is correct.

@github-actions github-actions Bot added the cli This issue is about cli application label Jan 9, 2026
@ChanTsune ChanTsune force-pushed the cli/list/jsonl-conditional-fields branch from 95b845c to f8e987d Compare January 9, 2026 02:15
Comment thread cli/src/command/list.rs Fixed
Comment thread cli/src/command/list.rs Fixed
The jsonl format was always outputting `acl` and `xattr` fields as
empty arrays regardless of whether -e (acl) or -@ (xattr) flags were
specified. This was inconsistent with the `fflags` field behavior.

Now these fields use `skip_serializing_if` to omit them entirely when
not requested, matching the expected behavior.

Also added tests to verify that:
- `-e` flag includes acl field in jsonl output
- `-@` flag includes xattr field in jsonl output
@ChanTsune ChanTsune force-pushed the cli/list/jsonl-conditional-fields branch from f8e987d to 91f6da3 Compare January 9, 2026 05:27
@ChanTsune ChanTsune merged commit 176cb4f into main Jan 18, 2026
100 checks passed
@ChanTsune ChanTsune deleted the cli/list/jsonl-conditional-fields branch January 18, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli This issue is about cli application

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants