Skip to content

Conversation

@blobaugh
Copy link
Contributor

Description

Add additional method to handle schema creation, schema existence checks, and listing actions.

@blobaugh blobaugh requested a review from a team as a code owner September 17, 2025 17:55
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.

Greptile Summary

This PR extends the WorkOS PHP SDK's audit logs functionality by adding comprehensive schema management capabilities. The changes introduce three new methods to the AuditLogs class:

  • createSchema() - Creates new audit log action schemas with validation
  • schemaExists() - Checks if a schema exists by attempting to fetch it and catching 404 exceptions
  • listActions() - Lists available audit log actions with pagination support (before/after cursors and ordering)

Additionally, the PR adds input validation to the existing getExport() method to prevent path traversal attacks. The validation uses regex patterns to allow only safe characters (alphanumeric, dots, underscores, hyphens) in action names and export IDs.

The implementation follows existing patterns in the codebase, using the same request/response handling approach as other audit log methods. The schemaExists() method uses exception handling to determine existence rather than a dedicated endpoint, catching NotFoundException when schemas don't exist and returning a boolean result.

Comprehensive test coverage has been added for all new methods, including both success scenarios and error cases (like 404 responses). The tests follow the established patterns with proper mocking, fixtures, and assertions, ensuring the new schema management features integrate seamlessly with the existing audit logs functionality.

Confidence score: 4/5

  • This PR is generally safe to merge but requires attention to input validation patterns
  • Score reflects solid implementation following existing patterns, but input validation could be more robust
  • Pay close attention to the input validation regex patterns in lib/AuditLogs.php

Context used:

Rule - All user inputs must be validated before processing (link)

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

@nave91
Copy link

nave91 commented Sep 18, 2025

Thank you so much for contributing to this SDK! The changes look good to me! However, it looks like a test is failing due to a linting error. Can you fix it, and I'd be happy to approve?

Let me know if you don't have time, and I can give it a shot.

1) lib/AuditLogs.php (no_trailing_whitespace_in_comment)
@nicknisi nicknisi merged commit c9f5a1c into workos:main Oct 23, 2025
5 checks passed
@antn antn mentioned this pull request Nov 20, 2025
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.

3 participants