Skip to content

Conversation

@hexedpackets
Copy link
Contributor

@hexedpackets hexedpackets commented Dec 29, 2025

Description

This new endpoint matches the response of the existing ID-based read method. Names have enforced uniqueness.

Documentation

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

[x] Yes

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

https://github.com/workos/workos/pull/49220

This new endpoint matches the response of the existing ID-based read
method. Names have enforced uniqueness.
@hexedpackets hexedpackets requested a review from a team as a code owner December 29, 2025 14:28
@greptile-apps
Copy link
Contributor

greptile-apps bot commented Dec 29, 2025

Greptile Summary

Added readObjectByName method to the Vault API that allows reading vault objects by their unique name instead of ID. The implementation mirrors the existing readObject method pattern, using the same response type and deserialization logic.

  • Added new readObjectByName(name: string) method in vault.ts:117-122 that calls /vault/v1/kv/name/{name} endpoint
  • Properly encodes the name parameter using encodeURIComponent to handle special characters
  • Reuses existing ReadObjectResponse type and deserializeObject serializer for consistent response handling
  • Added comprehensive unit test in vault.spec.ts:128-152 validating URL construction and response parsing
  • Added integration test in vault-live-test.spec.ts:73-103 verifying end-to-end functionality
  • Minor test cleanup: removed space in "MuskOx" test data and updated error message expectation to match current API behavior

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation follows established patterns exactly, properly handles input encoding, reuses existing types and serializers, and includes both unit and integration tests. No security concerns or breaking changes detected.
  • No files require special attention

Important Files Changed

Filename Overview
src/vault/vault.ts Added readObjectByName method that mirrors readObject but accepts a name string instead of options object with ID
src/vault/vault.spec.ts Added unit test for readObjectByName method with proper URL and response validation
src/vault/vault-live-test.spec.ts Added integration test for readObjectByName and minor test data cleanup (spacing in context values and error message)

Sequence Diagram

sequenceDiagram
    participant Client
    participant Vault
    participant WorkOS
    participant API as Vault API

    Client->>Vault: readObjectByName(name)
    Vault->>Vault: encodeURIComponent(name)
    Vault->>WorkOS: get(/vault/v1/kv/name/{name})
    WorkOS->>API: GET /vault/v1/kv/name/{name}
    API-->>WorkOS: ReadObjectResponse
    WorkOS-->>Vault: { data: ReadObjectResponse }
    Vault->>Vault: deserializeObject(data)
    Vault-->>Client: VaultObject
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.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@hexedpackets hexedpackets merged commit 31cde75 into main Dec 30, 2025
7 checks passed
@hexedpackets hexedpackets deleted the vault-read-by-name branch December 30, 2025 14:45
@hexedpackets hexedpackets mentioned this pull request Dec 30, 2025
hexedpackets added a commit that referenced this pull request Dec 30, 2025
## Description

Includes:
- #1424

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/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.
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