Skip to content

Reuse shared Base64 encoding for engine payloads - #6818

Merged
FredApps merged 1 commit into
mainfrom
extract/shared-engine-base64
Nov 16, 2026
Merged

FredApps merged 1 commit into
mainfrom
extract/shared-engine-base64

Conversation

@dylanmtaylor

@dylanmtaylor dylanmtaylor commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Replace the local engine Base64 encoder with existing craft-mime standard padded encoding.
  • Keep the decoder unchanged, including URL-safe symbols, optional padding and whitespace behavior; caller admission and picture policies remain unchanged.
  • Add RFC vectors, all-byte prefix/tail tests, no-wrap assertions and explicit decoder compatibility cases.

Dependencies and validation

Uses the existing workspace craft-mime revision 41fb227542efb8a7748caa1c659f271d8605303c. Cargo metadata adds only the engine dependency edge, no packages or version changes.
Metadata, rustfmt and git diff --check passed. No local builds/tests run; independent source review and hosted CI pending. This is an encoding-helper cutover, not the complete picture import or document-format extraction.

Summary by CodeRabbit

  • Refactor
    • Base64-encoded command payloads continue to use standard formatting, including padding and no line breaks. Decoding continues to accept standard and URL-safe symbols, whitespace, and optional padding, while rejecting invalid input. No user-facing behavior changes are indicated.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The engine now re-exports the base64 encoder from craft-mime instead of using its local implementation. Tests cover standard vectors, payload prefixes, output formatting, accepted input variants, and invalid input.

Changes: Shared Base64 Encoder

Layer / File(s) Summary
Adopt and validate shared encoder
crates/engine/Cargo.toml, crates/engine/src/cmd/insert/objects.rs, crates/engine/src/cmd/insert/tests.rs
The engine adds craft-mime and re-exports its base64 encoder. Tests check encoding vectors, payload prefixes, output formatting, decoder input handling, and invalid input.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Suggested reviewers: aiongg, dkhlapov

Merge Risk: Minimal · up to 86352

This swaps the engine's Base64 encoding helper for the shared implementation and adds tests for it. No concrete defect was found. Merge once hosted CI passes.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Reuse shared Base64 encoding for engine payloads" matches the main change. The PR replaces the engine's local base64_encode with the shared craft-mime encoder, and the removed function and …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Reuse shared Base64 encoding for engine payloads" matches the main change. The PR replaces the engine's local base64_encode with the shared craft-mime encoder, and the removed function and new shared-encoder test support this. The title is specific and short, and it does not describe anything absent from the changeset.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bc0e51e and 86352d5.

Files ignored due to path filters: 1

  • Cargo.lock is excluded by !**/*.lock
Files selected for processing: 3

  • crates/engine/Cargo.toml
  • crates/engine/src/cmd/insert/objects.rs
  • crates/engine/src/cmd/insert/tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@sonarqubecloud

Copy link
Copy Markdown

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed for craft-libs#778. base64_encode becomes a re-export of craft_mime::transfer::base64 (padded, unwrapped, standard alphabet, same as the removed encoder). The lenient local decoder is deliberately kept, and the new test covers RFC vectors, every length 0..=513 round-tripping through the existing decoder, and the +/// alphabet edge. craft-mime is already a workspace dependency, so there's no new pin. The red SonarCloud Scan job is pre-existing: coverage shards 1 and 4 fail the same way on main's SonarCloud runs, it isn't a required check, and the quality gate itself passed. CI is otherwise green.

@FredApps
FredApps merged commit 9088ed7 into main Nov 16, 2026
14 of 15 checks passed
@FredApps

Copy link
Copy Markdown
Contributor

Thanks @dylanmtaylor! Merged for storytold/craft-libs#778: WordCraft's engine payload Base64 encoder now reuses craft-mime's shared encoder (the lenient decoder stays local), with round-trip tests across every length up to 513 bytes.

@benandez
benandez deleted the extract/shared-engine-base64 branch November 23, 2026 19:59
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.

2 participants