Skip to content

fix:badge issuance error due to image data being removed from payload#401

Open
sujitaw wants to merge 1 commit into
mainfrom
fix/badge_issuance_image_missing_error
Open

fix:badge issuance error due to image data being removed from payload#401
sujitaw wants to merge 1 commit into
mainfrom
fix/badge_issuance_image_missing_error

Conversation

@sujitaw
Copy link
Copy Markdown
Contributor

@sujitaw sujitaw commented May 28, 2026

What

  • fixed the credential/sign endpoints type to accept image while signing

Summary by CodeRabbit

  • New Features
    • Added support for custom properties in credential objects, enabling enhanced flexibility for specialized credential use cases.

Review Change Stack

Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>
@sujitaw sujitaw self-assigned this May 28, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

📝 Walkthrough

Walkthrough

The CustomW3cJsonLdSignCredentialOptions type definition now permits arbitrary additional properties on the credential object via an index signature, broadening the type shape to accept extended custom fields.

Changes

W3C Credential Type Flexibility

Layer / File(s) Summary
Credential type index signature
src/controllers/types.ts
Index signature [key: string]: unknown added to the nested credential type inside CustomW3cJsonLdSignCredentialOptions, allowing callers to pass extra key/value pairs beyond the explicitly declared fields.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Possibly related PRs

  • credebl/agent-controller#384: Modifies the same CustomW3cJsonLdSignCredentialOptions type to loosen credential typing by allowing arbitrary additional properties via an index signature.

Poem

🐰 A credential gains flexibility bright,
With unknown keys held ever tight,
Extra fields now welcome with glee,
The shape expands wild and free! 🌟

🚥 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 accurately describes the main change: updating type definitions to allow image data in the credential payload during badge issuance, which directly addresses the file changes that add flexibility to accept arbitrary properties.
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.

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

✨ 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/badge_issuance_image_missing_error

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.

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/controllers/types.ts (1)

467-474: ⚡ Quick win

Consider documenting expected additional properties or defining known fields explicitly.

The index signature [key: string]: unknown on line 471 successfully allows arbitrary properties (such as image data) to be included in the credential object, which addresses the badge issuance issue. However, this reduces type safety by permitting any property without compile-time validation.

If the set of additional properties is known and limited (e.g., image, badgeClass, etc.), consider defining them explicitly as optional properties alongside the index signature. This would provide better IntelliSense support and catch typos at compile time while still allowing future extensions.

Alternatively, add a JSDoc comment documenting which additional properties are expected or commonly used.

📝 Example: Explicit property definition approach
 export type CustomW3cJsonLdSignCredentialOptions = Omit<W3cJsonLdSignCredentialOptions, 'format' | 'credential'> & {
   credential: Omit<W3cCredential, 'context' | 'credentialSubject'> & {
     '`@context`': Array<string | Record<string, unknown>>
     credentialSubject: SingleOrArray<JsonObject>
+    // Badge/image-related properties
+    image?: string | JsonObject
+    // Allow any other additional properties for extensibility
     [key: string]: unknown
   }
   [key: string]: unknown
 }
🤖 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 `@src/controllers/types.ts` around lines 467 - 474, The
CustomW3cJsonLdSignCredentialOptions type currently uses a broad index signature
that weakens type safety; update the type definition for
CustomW3cJsonLdSignCredentialOptions (and its nested credential property derived
from W3cCredential) to explicitly declare expected optional fields (e.g.,
image?: string | JsonObject, badgeClass?: string, etc.) alongside the existing
'`@context`' and credentialSubject properties, keeping the index signature for
forward compatibility; also add a brief JSDoc on
CustomW3cJsonLdSignCredentialOptions listing commonly used extra fields so
editors surface IntelliSense and typos are caught at compile time.
🤖 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.

Nitpick comments:
In `@src/controllers/types.ts`:
- Around line 467-474: The CustomW3cJsonLdSignCredentialOptions type currently
uses a broad index signature that weakens type safety; update the type
definition for CustomW3cJsonLdSignCredentialOptions (and its nested credential
property derived from W3cCredential) to explicitly declare expected optional
fields (e.g., image?: string | JsonObject, badgeClass?: string, etc.) alongside
the existing '`@context`' and credentialSubject properties, keeping the index
signature for forward compatibility; also add a brief JSDoc on
CustomW3cJsonLdSignCredentialOptions listing commonly used extra fields so
editors surface IntelliSense and typos are caught at compile time.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 43280239-c3f9-434d-a689-8eb6175bc70e

📥 Commits

Reviewing files that changed from the base of the PR and between eb93e12 and 925546b.

📒 Files selected for processing (1)
  • src/controllers/types.ts

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.

1 participant