Skip to content

sdk/internal: use lexicon strongRef type and schema in resolveRecordRef - #4

Merged
Kzoeps merged 2 commits into
mainfrom
sdk/use-lexicon-strongref
Nov 4, 2026
Merged

Kzoeps merged 2 commits into
mainfrom
sdk/use-lexicon-strongref

Conversation

@Kzoeps

@Kzoeps Kzoeps commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to TECH-752 (TECH-750 is now released).

Problem

resolveRecordRef defined its own StrongRef type and hand-checked the PDS response, waiting on @hypercerts-org/lexicon to publish record schemas. 2.0.1 now ships them.

Fix

  • StrongRef is now com.atproto.repo.strongRef's Main type from @hypercerts-org/lexicon.
  • The getRecord response is checked with that package's strongRef.main schema; the same-URI check stays. Error now reads "without a valid URI and CID".
  • @hypercerts-org/lexicon added as a peer dependency (^2.0.1), pinned as a dev dependency.
  • AGENTS.md validation notes updated to the real export layout.

Summary by CodeRabbit

  • Bug Fixes
    • Strong references are now checked for both a valid URI and CID, rather than validating only the CID.
    • Responses with invalid reference data or a URI that does not match the requested record now produce clearer error messages.

@hypercerts-org/lexicon 2.0.1 publishes record schemas, so the SDK no longer defines its own strong-ref shape or hand-checks the getRecord response. The package is added as a peer dependency.
@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Explain Change →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6a9c16bc-2188-4e7a-8e5a-97dfe22d9f90
Commits

Reviewing files that changed from the base of the PR and between cd0dadb and 79960dd.

Files selected for processing: 4
  • .github/workflows/ci.yml
  • AGENTS.md
  • README.md
  • package.json

No actionable comments were generated in the recent review.

Walkthrough

The SDK now uses the lexicon package’s strongRef.Main type and validates resolved record-reference responses against the com.atproto.repo.strongRef schema before comparing URIs. The package configuration, workspace settings, guidance, tests, and changeset are updated.

Changes: Lexicon Strong Reference Validation

Layer / File(s) Summary
Lexicon dependency and strong-reference type
packages/sdk/package.json, packages/sdk/src/internal/resolve-record-ref.ts, AGENTS.md, pnpm-workspace.yaml
The SDK adds @hypercerts-org/lexicon as a peer and development dependency. StrongRef now aliases strongRef.Main. Workspace release-age settings and SDK guidance are updated for the package.
Reference response validation
packages/sdk/src/internal/resolve-record-ref.ts, packages/sdk/src/internal/resolve-record-ref.test.ts, .changeset/lexicon-strongref.md
resolveRecordRef validates the full response body against the strong-reference schema before checking its URI. Invalid bodies produce an error referring to both URI and CID; URI mismatches report the returned URI. Tests and the changeset reflect these updates.

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

Change: Refactor

Possibly related PRs

Merge Risk: Minimal · previous review cd0da

Record references use the lexicon schema without an identified material merge risk.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: resolveRecordRef in the SDK internals now uses the lexicon package's strongRef type and schema instead of a local StrongRef shape and hand-written checks. The raw summ…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
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 names the main change: resolveRecordRef in the SDK internals now uses the lexicon package's strongRef type and schema instead of a local StrongRef shape and hand-written checks. The raw summary confirms this change in resolve-record-ref.ts, with supporting changes to package.json, the changeset, and pnpm-workspace.yaml. The title is specific and matches the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files. (4 skipped: 4 unsupported.)

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f1a62984-f5b7-400c-88fe-e25ea1d48f7d
Commits

Reviewing files that changed from the base of the PR and between e601d3f and cd0dadb.

Files ignored due to path filters: 1
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 6
  • .changeset/lexicon-strongref.md
  • AGENTS.md
  • packages/sdk/package.json
  • packages/sdk/src/internal/resolve-record-ref.test.ts
  • packages/sdk/src/internal/resolve-record-ref.ts
  • pnpm-workspace.yaml

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

@socket-security

socket-security Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​hypercerts-org/​lexicon@​2.0.18410010098100

View full report

--similarity misses functions rewritten in a different style. jscpd --semantic compares embeddings from a local model; 0.55 catches hand-written rewrites of describe.ts helpers that the default 0.6375 misses, with no false matches in the SDK today. The model is cached in CI.
@sonarqubecloud

sonarqubecloud Bot commented Nov 4, 2026

Copy link
Copy Markdown

❌ The last analysis has failed.

See analysis details on SonarQube Cloud

@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

@Kzoeps
Kzoeps merged commit fb1cba8 into main Nov 4, 2026
9 of 10 checks passed
@Kzoeps
Kzoeps deleted the sdk/use-lexicon-strongref branch November 4, 2026 08:25
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