Skip to content

Conversation

@sujitaw
Copy link
Contributor

@sujitaw sujitaw commented Dec 3, 2025

what

  • fixed the get formatted data issue when doing issuance using shared agent due to incorrect agent context.

Summary by CodeRabbit

  • Improvements
    • Enhanced credential event processing for multi-tenant deployments: events now correctly distinguish default vs tenant-specific contexts, resolving connections and credential data within the appropriate tenant scope. This improves data isolation and ensures reliable webhook and optional WebSocket notifications across tenant boundaries.

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

Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>
@sujitaw sujitaw self-assigned this Dec 3, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 3, 2025

Walkthrough

Credential event processing now conditionally uses tenant-scoped agents when a non-default contextCorrelationId is present; connection records and credential format data are retrieved via the tenant agent in that case, otherwise the global agent is used, before emitting webhooks and optional WebSocket notifications.

Changes

Cohort / File(s) Summary
Multi-tenant credential event handling
src/events/CredentialEvents.ts
Added branching on contextCorrelationId to select between tenant-scoped (withTenantAgent) and global agent calls. Both connection record lookup and credential format data retrieval are now performed via the chosen agent before continuing event emission and WebSocket notification logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file change introducing conditional agent selection for multi-tenant support.
  • Review focus:
    • Correct selection and usage of tenant vs. global agent.
    • Consistent handling of connectionRecord and credentialData across branches.
    • No changes to exported/public API surface.

Poem

🐰
Hopped through contexts, ears alert and fleet,
Tenant or global — I choose the right seat.
Fetching connections with careful delight,
Emitting the echoes into the night,
A rabbit's small dance for code made neat. 🌿

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'fix: resolve data error on issuance using shared agent' directly aligns with the main change: fixing credential issuance by correcting agent context handling for data retrieval.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/get_formatted_data_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.

Copy link

@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: 3

🧹 Nitpick comments (1)
src/events/CredentialEvents.ts (1)

23-48: Consider extracting tenant-aware execution pattern.

The tenant-check-and-execute pattern is duplicated. A helper would reduce repetition and ensure consistent handling:

async function withContextAgent<T>(
  agent: Agent<RestMultiTenantAgentModules>,
  contextId: string | undefined,
  action: (ctx: typeof agent) => Promise<T>
): Promise<T> {
  if (contextId && contextId !== 'default') {
    let result: T
    await agent.modules.tenants.withTenantAgent({ tenantId: contextId }, async (tenantAgent) => {
      result = await action(tenantAgent as typeof agent)
    })
    return result!
  }
  return action(agent)
}

Then usage becomes:

connectionRecord = await withContextAgent(agent, event.metadata.contextCorrelationId, 
  (ctx) => ctx.connections.findById(record.connectionId)
)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a8165c4 and 35582f0.

📒 Files selected for processing (1)
  • src/events/CredentialEvents.ts (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/events/CredentialEvents.ts (1)
src/cliAgent.ts (1)
  • RestMultiTenantAgentModules (115-115)
🪛 ESLint
src/events/CredentialEvents.ts

[error] 7-8: Delete

(prettier/prettier)


[error] 35-36: Delete

(prettier/prettier)

🪛 GitHub Actions: Continuous Integration
src/events/CredentialEvents.ts

[error] 7-7: Delete prettier/prettier

🪛 GitHub Check: SonarCloud Code Analysis
src/events/CredentialEvents.ts

[warning] 28-28: This assertion is unnecessary since the receiver accepts the original type of the expression.

See more on https://sonarcloud.io/project/issues?id=credebl_afj-controller&issues=AZrilbDDmKr6wbF74bHb&open=AZrilbDDmKr6wbF74bHb&pullRequest=332


[warning] 32-32: This assertion is unnecessary since the receiver accepts the original type of the expression.

See more on https://sonarcloud.io/project/issues?id=credebl_afj-controller&issues=AZrilbDDmKr6wbF74bHc&open=AZrilbDDmKr6wbF74bHc&pullRequest=332


[warning] 39-39: Unexpected negated condition.

See more on https://sonarcloud.io/project/issues?id=credebl_afj-controller&issues=AZrilbDDmKr6wbF74bHd&open=AZrilbDDmKr6wbF74bHd&pullRequest=332


[warning] 24-24: Unexpected negated condition.

See more on https://sonarcloud.io/project/issues?id=credebl_afj-controller&issues=AZrilbDCmKr6wbF74bHa&open=AZrilbDCmKr6wbF74bHa&pullRequest=332

🪛 GitHub Check: Validate
src/events/CredentialEvents.ts

[failure] 7-7:
Delete


[failure] 35-35:
Delete

Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 3, 2025

@ajile-in ajile-in changed the title fix:resolved get formatted data error on issuance using shared agent fix: resolve data error on issuance using shared agent Dec 4, 2025
@sujitaw sujitaw merged commit 104f72a into main Dec 8, 2025
9 checks passed
kinxa0 pushed a commit to Bhutan-NDI/ngotag-agent-controller that referenced this pull request Jan 7, 2026
* fix/get formatted data error

Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>

* fix/ellipse comments

Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>

---------

Signed-off-by: sujitaw <sujit.sutar@ayanworks.com>
Signed-off-by: kinxa0 <kinzangdorji@bhutanndi.bt>
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.

4 participants