Skip to content

Conversation

@blobaugh
Copy link
Contributor

Update PHPDoc to include missing intent values (certificate_renewal, domain_verification) and add runtime validation for $intent parameter to provide better error messages before API calls. Includes test coverage for all intent values and invalid intent handling.

Fixes #295

Description

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

Update PHPDoc to include missing intent values (certificate_renewal,
domain_verification) and add runtime validation for $intent parameter
to provide better error messages before API calls. Includes test
coverage for all intent values and invalid intent handling.

Fixes workos#295
@blobaugh blobaugh requested a review from a team as a code owner November 25, 2025 16:24
@blobaugh blobaugh requested a review from mattgd November 25, 2025 16:24
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 25, 2025

Greptile Overview

Greptile Summary

Updated PHPDoc and added runtime validation for Portal intent parameter to address issue #295.

Changes:

  • Added missing certificate_renewal and domain_verification to intent documentation in lib/Portal.php:16
  • Implemented runtime validation that throws UnexpectedValueException for invalid intent values before API calls
  • Added test coverage for both new intent values and invalid intent handling

The implementation follows existing validation patterns used elsewhere in the codebase (e.g., SSO.php) and provides clear error messages to developers.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes are straightforward documentation and validation updates with comprehensive test coverage. The validation pattern follows existing codebase conventions, and all custom security rules are satisfied (no SQL injection, CORS issues, or sensitive data logging).
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
lib/Portal.php 5/5 Added missing intent values (certificate_renewal, domain_verification) to PHPDoc and implemented validation for intent parameter
tests/WorkOS/PortalTest.php 5/5 Added comprehensive test coverage for new intent values and invalid intent handling

Sequence Diagram

sequenceDiagram
    participant Client as Client Code
    participant Portal as Portal.generateLink()
    participant Validation as Intent Validation
    participant API as WorkOS API

    Client->>Portal: generateLink(org, intent, returnUrl, successUrl)
    Portal->>Validation: Check intent in validIntents array
    alt Invalid Intent
        Validation-->>Client: throw UnexpectedValueException
    else Valid Intent
        Validation->>Portal: Continue
        Portal->>API: POST /portal/generate_link
        API-->>Portal: Return portal link
        Portal-->>Client: Return PortalLink resource
    end
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Member

@nicknisi nicknisi left a comment

Choose a reason for hiding this comment

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

Thank you!

@nicknisi nicknisi merged commit b37dad7 into workos:main Nov 26, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Possible values for intent incomplete

2 participants