Skip to content

fix: add $type for contributor identity and contribution details StrongRefs#119

Merged
aspiers merged 1 commit into
developfrom
fix/contributors-record
Jan 27, 2026
Merged

fix: add $type for contributor identity and contribution details StrongRefs#119
aspiers merged 1 commit into
developfrom
fix/contributors-record

Conversation

@Kzoeps
Copy link
Copy Markdown
Contributor

@Kzoeps Kzoeps commented Jan 26, 2026

Summary

Fixes lexicon validation errors when creating hypercerts with contributors by ensuring contributorIdentity and contributionDetails StrongRefs include $type: "com.atproto.repo.strongRef".

Root Cause

The lexicon defines contributorIdentity and contributionDetails as union types wrapped in $Typed<>, which requires $type as a discriminator for validation. Unlike the rights field (which uses plain ComAtprotoRepoStrongRef.Main), these fields require $type to pass validation.

Changes

Implementation

  • resolveContributorIdentity(): Now converts string DIDs to contributorInformation records and returns StrongRefs with $type
  • resolveContributionDetails(): Added $type: "com.atproto.repo.strongRef" to all StrongRef returns
  • Type definitions: Updated ResolvedContributorIdentity and ResolvedContributionDetails types to include $type in StrongRef objects

Tests

  • Added mocks for contributorInformation record creation when string DIDs are provided
  • Updated assertions to expect $type: "com.atproto.repo.strongRef" in all StrongRefs
  • Adjusted mock call indices to account for additional record creation calls
  • Fixed 10 failing tests

Test Results

  • Before: 10 failing tests (652 total)
  • After: All 652 tests passing ✅

Impact

This ensures hypercert records with contributors pass lexicon validation and can be created successfully without validation errors.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed contributor and contribution strong references to properly include type discriminators for consistent object identification across resolution paths.
  • Tests

    • Updated test cases to verify contributor information record creation and validation of strong reference type discriminators in multiple resolution scenarios.

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jan 26, 2026

🦋 Changeset detected

Latest commit: 2354987

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@hypercerts-org/sdk-core Patch
@hypercerts-org/sdk-react Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

The PR adds $type: "com.atproto.repo.strongRef" discriminator fields to StrongRef objects returned by contributor and contribution resolution methods. Public types are updated to include this field for proper lexicon validation. Implementation and tests are updated accordingly.

Changes

Cohort / File(s) Summary
Type Definitions
packages/sdk-core/src/repository/interfaces.ts
Updated ResolvedContributorIdentity and ResolvedContributionDetails types to include $type: "com.atproto.repo.strongRef" in their StrongRef object variants
Implementation
packages/sdk-core/src/repository/HypercertOperationsImpl.ts
Added $type discriminator field to StrongRef objects returned from resolveContributorIdentity(), resolveContributionDetails(), and related contributor resolution paths
Tests
packages/sdk-core/tests/repository/HypercertOperationsImpl.test.ts
Updated test mocks and assertions to expect $type field in returned StrongRefs; adjusted expected call counts for contributor information record creation
Documentation
.changeset/fix-contributor-strongref-types.md
Changeset documenting the addition of $type discriminators to StrongRef objects for lexicon validation

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • bitbeckers
  • aspiers

Poem

🐰 With whisker-twitching delight, we add the type so right,
StrongRefs now wear their badges bright—discriminators in the light!
From contributor's den to details refined,
Lexicon validation's peace of mind!

🚥 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 accurately and specifically describes the main change: adding the $type discriminator to StrongRef objects for contributor identity and contribution details fields.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@aspiers aspiers merged commit af0dfc0 into develop Jan 27, 2026
4 checks passed
@aspiers aspiers deleted the fix/contributors-record branch January 27, 2026 04:07
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