Skip to content

fix(sheets): recognize OFL0X local office tokens - #2063

Merged
zhengzhijiej-tech merged 1 commit into
mainfrom
fix/sheets-ofl0x-office-token
Jul 28, 2026
Merged

fix(sheets): recognize OFL0X local office tokens#2063
zhengzhijiej-tech merged 1 commit into
mainfrom
fix/sheets-ofl0x-office-token

Conversation

@zhengzhijiej-tech

@zhengzhijiej-tech zhengzhijiej-tech commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Problem

Local Office spreadsheet tokens now use a 28-character interleaved format. The CLI only recognized the legacy fake_office_ and local_office_ prefixes, so local-image uploads for the new tokens selected parent_type=sheet_image instead of the required office_sheet_file.

Changes

  • Recognize a 28-character token as a local Office spreadsheet when positions 5, 10, 15, 20, and 25 form OFL0X.
  • Keep the legacy prefix checks for compatibility.
  • Apply the same classification to the current sheets shortcuts and the backward-compatible media upload path.
  • Cover +media-upload, +cells-set-image, and +float-image-create, including native and malformed-token negative cases.

Validation

  • go test -count=1 ./shortcuts/sheets/...
  • go vet ./shortcuts/sheets/...
  • ./build.sh
  • go test -count=1 ./tests/cli_e2e/sheets -run TestSheets_ImageUploadDryRunParentType
  • make quality-gate

Summary by CodeRabbit

  • Bug Fixes

    • Improved image upload parent-type handling for imported Office spreadsheets by expanding detection of legacy synthetic tokens and the newer interleaved OFL0X marker, ensuring uploads map to office_sheet_file (while non-Office/natively handled sheets continue to use sheet_image).
  • Tests

    • Updated unit and end-to-end dry-run cases to use the new OFL0X office token and revised expectations across media-upload, cells-set-image, and float-image-create flows.

@github-actions github-actions Bot added domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact labels Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 034f1f9c-07b9-488b-befb-67b183491a1b

📥 Commits

Reviewing files that changed from the base of the PR and between 5249125 and 03ea5ce.

📒 Files selected for processing (5)
  • shortcuts/sheets/backward/lark_sheets_float_images.go
  • shortcuts/sheets/backward/lark_sheets_sheet_media_upload_test.go
  • shortcuts/sheets/helpers.go
  • shortcuts/sheets/sheet_media_parent_type_test.go
  • tests/cli_e2e/sheets/sheets_image_upload_dryrun_test.go
🚧 Files skipped from review as they are similar to previous changes (5)
  • shortcuts/sheets/backward/lark_sheets_sheet_media_upload_test.go
  • shortcuts/sheets/sheet_media_parent_type_test.go
  • shortcuts/sheets/helpers.go
  • shortcuts/sheets/backward/lark_sheets_float_images.go
  • tests/cli_e2e/sheets/sheets_image_upload_dryrun_test.go

📝 Walkthrough

Walkthrough

Spreadsheet media parent-type logic now recognizes imported office spreadsheets through legacy prefixes or interleaved OFL0X tokens. Unit, upload, and CLI dry-run tests cover the expanded classification.

Changes

Office spreadsheet parent-type mapping

Layer / File(s) Summary
Office token classifier
shortcuts/sheets/backward/lark_sheets_float_images.go, shortcuts/sheets/helpers.go
Adds parent-type constants and classifies office spreadsheets using legacy prefixes or 28-character interleaved tokens containing OFL0X.
Parent-type selection and unit coverage
shortcuts/sheets/backward/lark_sheets_float_images.go, shortcuts/sheets/helpers.go, shortcuts/sheets/sheet_media_parent_type_test.go
Routes parent-type selection through the classifier and tests legacy, interleaved, and non-office token formats.
Upload surface validation
shortcuts/sheets/backward/lark_sheets_sheet_media_upload_test.go, tests/cli_e2e/sheets/sheets_image_upload_dryrun_test.go
Updates upload and dry-run cases to use an interleaved office token and expect office_sheet_file.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • larksuite/cli#1606: Extends the related sheetMediaParentType and office_sheet_file mapping with broader token detection.

Suggested reviewers: fangshuyu-768

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 72.73% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: recognizing OFL0X local office tokens.
Description check ✅ Passed The description covers the problem, changes, and validation, but it uses different headings and omits a Related Issues section.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/sheets-ofl0x-office-token

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
shortcuts/sheets/helpers.go (1)

60-90: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy lift

Keep office-token recognition in one shared implementation.

  • shortcuts/sheets/helpers.go#L60-L90: make this the single shared classifier.
  • shortcuts/sheets/backward/lark_sheets_float_images.go#L24-L54: remove the duplicate constants/helper and reuse the shared implementation.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@shortcuts/sheets/helpers.go` around lines 60 - 90, Keep isOfficeSpreadsheet
in shortcuts/sheets/helpers.go as the sole shared office-token classifier,
including its constants and prefix definitions. In
shortcuts/sheets/backward/lark_sheets_float_images.go lines 24-54, remove the
duplicate constants and helper and update callers to reuse the shared
isOfficeSpreadsheet implementation; no direct change is needed in helpers.go
beyond preserving it as the shared source.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@shortcuts/sheets/sheet_media_parent_type_test.go`:
- Around line 45-48: Update the four interleaved non-office token fixtures in
the sheet media parent type tests to be 28 bytes long by appending a filler
byte, while preserving their non-OFL0X markers and expected sheetImageParentType
result.

---

Nitpick comments:
In `@shortcuts/sheets/helpers.go`:
- Around line 60-90: Keep isOfficeSpreadsheet in shortcuts/sheets/helpers.go as
the sole shared office-token classifier, including its constants and prefix
definitions. In shortcuts/sheets/backward/lark_sheets_float_images.go lines
24-54, remove the duplicate constants and helper and update callers to reuse the
shared isOfficeSpreadsheet implementation; no direct change is needed in
helpers.go beyond preserving it as the shared source.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 90a72427-eafb-43f4-b409-80a151b4d69a

📥 Commits

Reviewing files that changed from the base of the PR and between 56c9a2a and 7a3fe5a.

📒 Files selected for processing (5)
  • shortcuts/sheets/backward/lark_sheets_float_images.go
  • shortcuts/sheets/backward/lark_sheets_sheet_media_upload_test.go
  • shortcuts/sheets/helpers.go
  • shortcuts/sheets/sheet_media_parent_type_test.go
  • tests/cli_e2e/sheets/sheets_image_upload_dryrun_test.go

Comment thread shortcuts/sheets/sheet_media_parent_type_test.go
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.16%. Comparing base (56c9a2a) to head (03ea5ce).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...rtcuts/sheets/backward/lark_sheets_float_images.go 92.85% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2063   +/-   ##
=======================================
  Coverage   75.15%   75.16%           
=======================================
  Files         912      912           
  Lines       96453    96477   +24     
=======================================
+ Hits        72492    72514   +22     
- Misses      18383    18384    +1     
- Partials     5578     5579    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zhengzhijiej-tech
zhengzhijiej-tech force-pushed the fix/sheets-ofl0x-office-token branch from 5249125 to 03ea5ce Compare July 27, 2026 08:15
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

🚀 PR Preview Install Guide

🧰 CLI update

npm i -g https://pkg.pr.new/larksuite/cli/@larksuite/cli@03ea5cefd584fdab221cf7f3a184d8f832f8e52b

🧩 Skill update

npx skills add larksuite/cli#fix/sheets-ofl0x-office-token -y -g

@zhengzhijiej-tech
zhengzhijiej-tech merged commit 1b173e1 into main Jul 28, 2026
27 of 40 checks passed
@zhengzhijiej-tech
zhengzhijiej-tech deleted the fix/sheets-ofl0x-office-token branch July 28, 2026 07:09
@liangshuo-1 liangshuo-1 mentioned this pull request Jul 28, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain/ccm PR touches the ccm domain size/M Single-domain feat or fix with limited business impact

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants