Skip to content

docs(sdks): document TDF decrypt convenience helpers - #379

Merged
marythought merged 8 commits into
mainfrom
docs/tdf-decrypt-helpers
Aug 4, 2026
Merged

docs(sdks): document TDF decrypt convenience helpers#379
marythought merged 8 commits into
mainfrom
docs/tdf-decrypt-helpers

Conversation

@marythought

@marythought marythought commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Documents the new Go SDK DecryptBytes/DecryptTo/DecryptFile convenience helpers added in opentdf/platform#3828.

  • Adds a Decrypt Helpers section to docs/sdks/tdf.mdx (between LoadTDF and IsValidTdf): signatures, examples, DecryptFile's temp-file/rename/backup-restore behavior, and an Errors table covering ErrTDFNotDecryptable/ErrTDFDecryptFailed with an errors.Is example.
  • Updates docs/sdks/quickstart/go.mdx — all three places that manually did LoadTDF + WriteTo (the Step 3 running example, "Save TDF to a File", and the "Complete Reference Implementation") now use the new helpers.

Modeled on the existing BulkDecrypt section's structure (Go-only convenience methods don't need forced <Tabs> shells for Java/JS). Heading names (DecryptBytes/DecryptTo/DecryptFile) are unique across the page and its imported code_samples/*.mdx files, per the anchor-collision rule in AGENTS.md.

Test plan

  • vale docs/sdks/tdf.mdx docs/sdks/quickstart/go.mdx — 0 errors, warnings, or suggestions.
  • Every code example and behavior claim cross-checked against the actual implementation in feat(sdk): add TDF decrypt convenience helpers platform#3828 (sdk/decrypt.go, sdk/decrypterrors.go).
  • Checked for heading/anchor collisions across tdf.mdx and its imports — none.

Summary by CodeRabbit

  • Documentation
    • Simplified Go SDK quickstart examples for in-memory and file-based decryption.
    • Added guidance for decrypting data to memory, writers, and files.
    • Documented payload limits, streaming behavior, error classification, and file safety protections.
    • Clarified that manifest assertions are verified through the standard TDF loading flow.

Add a Decrypt Helpers section to the TDF SDK reference (DecryptBytes,
DecryptTo, DecryptFile — thin wrappers over LoadTDF + WriteTo, plus the
ErrTDFNotDecryptable / ErrTDFDecryptFailed sentinels), and update the Go
quickstart's decrypt examples to use them instead of the manual
LoadTDF + WriteTo sequence.

Corresponds to opentdf/platform#3828.

Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
@marythought
marythought requested review from a team as code owners August 4, 2026 15:09
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Go SDK documentation adds DecryptBytes, DecryptTo, and DecryptFile. Quickstart examples use the helpers for byte and file decryption. The assertion example continues to use LoadTDF when manifest assertions are required.

Changes

Go decryption helpers

Layer / File(s) Summary
Document decryption helper methods
docs/sdks/tdf.mdx
Documents DecryptBytes, DecryptTo, and DecryptFile, including streaming, error classification, and atomic file replacement.
Update quickstart decryption flows
docs/sdks/quickstart/go.mdx, code_samples/tdf/assertion_examples.mdx
Replaces manual decryption flows with the helper methods. The assertion example retains LoadTDF for manifest assertion access.

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

Possibly related PRs

  • opentdf/docs#268: Updates the assertion example to clarify when LoadTDF is required.

Suggested reviewers: elizabethhealy, jp-ayyappan

Poem

A rabbit checks each byte with care,
Three helpers guide plaintext there.
Files replace through guarded flight,
Quickstarts show the method right.
Assertions keep LoadTDF in sight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the documentation changes for TDF decrypt convenience helpers.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/tdf-decrypt-helpers

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

🤖 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 `@docs/sdks/tdf.mdx`:
- Around line 570-588: Update the error-handling example for DecryptBytes,
DecryptTo, and DecryptFile so the fallback case no longer lists writer errors as
outside the documented categories; remove that example or describe only
unexpected errors outside the helper contract, while preserving the
ErrTDFNotDecryptable and ErrTDFDecryptFailed branches.
🪄 Autofix

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2598c24a-daf9-4590-938d-3380bd0866e1

📥 Commits

Reviewing files that changed from the base of the PR and between 82d13de and 22f72a8.

📒 Files selected for processing (2)
  • docs/sdks/quickstart/go.mdx
  • docs/sdks/tdf.mdx

Comment thread docs/sdks/tdf.mdx
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

📄 Preview deployed to https://opentdf-docs-pr-379.surge.sh

The switch example's fallback case described writer errors as an
uncategorized "other failure," contradicting the preceding table, which
correctly classifies writer errors under ErrTDFDecryptFailed. Every
failure from all three helpers wraps one of the two sentinels, so drop
the misleading third case.

Flagged by CodeRabbit on #379.

Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
DecryptBytes now rejects payloads over 1 GiB before buffering, since it
holds the full plaintext in memory unlike DecryptTo/DecryptFile.

Corresponds to opentdf/platform#3828.

Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
…ntence

The 1 GiB limit was buried in the intro sentence before the Signature —
easy to miss. Give it its own callout paragraph after the Example,
matching how DecryptFile's behavior notes are presented. Also reword the
"no third, uncategorized case" sentence, which read awkwardly.

Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
The Decrypt Helpers signatures use opts ...TDFReaderOption but never
linked to what it is, unlike LoadTDF's own Parameters table.

Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
Was a parenthetical inside the Pre-decrypt failure row's Cause column —
easy to miss. Split it into its own row.

Signed-off-by: Mary Dickson <mary.dickson@virtru.com>
…ss-link

- All three Decrypt Helpers signatures/examples now take ctx context.Context
  as their first parameter, matching opentdf/platform#3828's review-driven
  signature change (ctx governs the KAS rewrap request).
- Add <SdkVersion language="go" version="0.29.0" .../> under each of the
  three Signatures, matching the established per-Signature placement
  convention used elsewhere in this file.
- Cross-link from assertion_examples.mdx's End-to-End Example to Decrypt
  Helpers, explaining why that example stays on LoadTDF directly (it reads
  tdfReader.Manifest().Assertions, which the helpers don't expose).

Signed-off-by: Mary Dickson <mary.dickson@virtru.com>

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/sdks/tdf.mdx (2)

574-584: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Align the documented error contract with decrypt helper returns.

The DecryptFile helper can return file-system and validation errors instead of only sdk.ErrTDFNotDecryptable or sdk.ErrTDFDecryptFailed. Either have the SDK wrap those paths with the same sentinels, or update this table/example to call out an unclassified DecryptFile fallback path.

🤖 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 `@docs/sdks/tdf.mdx` around lines 574 - 584, Update the Errors documentation
for DecryptFile to reflect its actual file-system and validation error behavior,
either by documenting an unclassified fallback path or by changing the SDK
implementation so every such failure is wrapped with ErrTDFNotDecryptable or
ErrTDFDecryptFailed. Keep the documented errors.Is/errors.As contract consistent
across DecryptBytes, DecryptTo, and DecryptFile.

Source: MCP tools


530-532: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Document partial writes for streaming decryption output.

DecryptTo calls the TDFReader.WriteTo stream path, where payload-integrity checks can fail after plaintext bytes have already been written. A destination such as an HTTP response can therefore end with partial plaintext. For all-or-nothing output, recommend buffering the write and returning it only after decryption completes without error.

🤖 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 `@docs/sdks/tdf.mdx` around lines 530 - 532, Update the DecryptTo documentation
to state that streaming decryption may write partial plaintext before a
payload-integrity error occurs. Recommend buffering output and releasing it only
after decryption completes successfully when all-or-nothing output is required.

Source: MCP tools

🤖 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 `@code_samples/tdf/assertion_examples.mdx`:
- Line 59: Revise the explanatory text around the LoadTDF assertion example to
distinguish the helper outputs precisely: DecryptBytes returns plaintext bytes,
while DecryptTo and DecryptFile write plaintext to their destinations and return
only an error. Keep the rationale that LoadTDF is required to access
tdfReader.Manifest().Assertions.

---

Outside diff comments:
In `@docs/sdks/tdf.mdx`:
- Around line 574-584: Update the Errors documentation for DecryptFile to
reflect its actual file-system and validation error behavior, either by
documenting an unclassified fallback path or by changing the SDK implementation
so every such failure is wrapped with ErrTDFNotDecryptable or
ErrTDFDecryptFailed. Keep the documented errors.Is/errors.As contract consistent
across DecryptBytes, DecryptTo, and DecryptFile.
- Around line 530-532: Update the DecryptTo documentation to state that
streaming decryption may write partial plaintext before a payload-integrity
error occurs. Recommend buffering output and releasing it only after decryption
completes successfully when all-or-nothing output is required.
🪄 Autofix

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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: bee637de-e40c-4d3a-a66c-0d97a65a5305

📥 Commits

Reviewing files that changed from the base of the PR and between a4d8099 and 570c97b.

📒 Files selected for processing (3)
  • code_samples/tdf/assertion_examples.mdx
  • docs/sdks/quickstart/go.mdx
  • docs/sdks/tdf.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • docs/sdks/quickstart/go.mdx

Comment thread code_samples/tdf/assertion_examples.mdx
@marythought
marythought merged commit 60c14c6 into main Aug 4, 2026
10 checks passed
@marythought
marythought deleted the docs/tdf-decrypt-helpers branch August 4, 2026 18:23
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