Skip to content

docs(function): return results directly in managing-idp-users samples#156

Merged
anukiransolur merged 2 commits into
mainfrom
idp-users-return-style
Jul 2, 2026
Merged

docs(function): return results directly in managing-idp-users samples#156
anukiransolur merged 2 commits into
mainfrom
idp-users-return-style

Conversation

@k1LoW

@k1LoW k1LoW commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

The Managing Built-in IdP Users guide showed samples that wrapped method results in a { success: ... } (or { success: true }) object. Because the tailor.idp client methods reject on failure, that wrapping reads as if the samples presuppose try/catch-based error handling, and it implicitly recommends returning a success/error result object. This updates every sample in the guide to return the meaningful value directly and let errors propagate as thrown exceptions — matching the recommended "throw unless you need to control the error or its message" style.

Changes

  • docs/guides/function/managing-idp-users.md — remove the { success } result-object framing from every sample:
    • Create User / Update User — drop the redundant success: true field; return only the meaningful record data (userId, userName, disabled, …).
    • Delete User / Send Password Reset Email / Unenroll MFA Factor (single) — these methods resolve to a boolean and throw on error, so return that result directly instead of re-wrapping it as { success }.
    • Unenroll MFA Factor (reset all) — drop the { success: false, reason } guard and the results.every(Boolean) aggregation; return the list of unenrolled factor IDs ({ unenrolledFactorIds }) and let any failure throw.

No prose sections were added or removed; only the sample code returns changed.

Verification

  • pnpm build ✅ (guide renders)
  • pnpm lint ✅ (no new issues)

The `tailor.idp` client methods reject on failure, so wrapping their
results in a `{ success }` object made the samples read as if they
presuppose try/catch-based error handling — and implicitly recommended
returning a result object. Return the meaningful value directly and let
errors propagate as thrown exceptions, so the samples reflect the
recommended "throw unless you need to control the error or its message"
style rather than a success/error result object.

This comment was marked as outdated.

@k1LoW k1LoW self-assigned this Jul 2, 2026
…d factors

Apply Copilot review feedback on the managing-idp-users samples.

- Drop the redundant `await` from the `deleteUser`, `sendPasswordResetEmail`,
  and single-factor `unenrollMfa` samples. With no surrounding `try`/`catch`,
  returning the promise directly is equivalent and reads more simply.
- In the reset-all-MFA sample, filter `user.mfaFactorIds` by the boolean
  results of `unenrollMfa()` so `unenrolledFactorIds` reflects the factors
  that were actually unenrolled, rather than assuming every factor succeeded.

Copilot AI 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.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@k1LoW
k1LoW marked this pull request as ready for review July 2, 2026 04:46
@k1LoW
k1LoW requested a review from a team as a code owner July 2, 2026 04:46
@anukiransolur
anukiransolur merged commit a320459 into main Jul 2, 2026
4 checks passed
@anukiransolur
anukiransolur deleted the idp-users-return-style branch July 2, 2026 18:01
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.

3 participants