Skip to content

Conversation

@aaearon
Copy link
Contributor

@aaearon aaearon commented Jul 30, 2025

Desired Outcome

Fix the ArkPCloudPlatformsService.platform() method that fails with Pydantic validation errors when calling the Platform Details API endpoint. The SDK was attempting to validate the API response against an incorrect model structure.

Implemented Changes

What's changed:

  • Added new ArkPCloudPlatformDetails model that matches the actual Platform Details API response format ({"PlatformID": "X", "Active": true, "Details": {...}})
  • Updated platform() method to return ArkPCloudPlatformDetails instead of ArkPCloudPlatform
  • Fixed import_platform() method to return platform ID string (matching Import Platform API response) instead of attempting to fetch platform details
  • Updated model exports and imports

Why these changes were made:
The Platform Details API (/platforms/{id}) returns a different structure than the List Platforms API (/platforms). The SDK was incorrectly trying to parse the flat Platform Details response against the nested List Platforms model structure.

How to review:

  • Verify the new ArkPCloudPlatformDetails model correctly maps to the API response from issue Platform Details API Pydantic validation fails in v2.0.14 #44
  • Confirm platform() method now successfully parses Platform Details API responses
  • Check that import_platform() correctly returns the platform ID string as per Import Platform API specification

Connected Issue/Story

Resolves #44

CyberArk internal issue ID: N/A

Definition of Done

Changelog

  • The CHANGELOG has been updated, or
  • This PR does not include user-facing changes and doesn't require a CHANGELOG update

Test coverage

  • This PR includes new unit and integration tests to go with the code changes, or
  • The changes in this PR do not require tests

Documentation

  • Docs (e.g. READMEs) were updated in this PR
  • A follow-up issue to update official docs has been filed here: [insert issue ID]
  • This PR does not require updating any documentation

Behavior

  • This PR changes product behavior and has been reviewed by a PO, or
  • These changes are part of a larger initiative that will be reviewed later, or
  • No behavior was changed with this PR

Security

  • Security architect has reviewed the changes in this PR,
  • These changes are part of a larger initiative with a separate security review, or
  • There are no security aspects to these changes

aaearon added 3 commits July 30, 2025 21:16
The ArkPCloudPlatformsService.platform() method was failing with Pydantic
validation errors because it tried to validate the Platform Details API
response against the wrong model structure.

Root cause:
- Platform Details API (/platforms/{id}) returns:
  {"PlatformID": "X", "Active": true, "Details": {...}}
- List Platforms API (/platforms) returns structured data that fits
  ArkPCloudPlatform model with nested sections

Changes:
- Add new ArkPCloudPlatformDetails model matching actual API response format
- Update platform() method to return ArkPCloudPlatformDetails instead of ArkPCloudPlatform
- Update import_platform() method return type for consistency
- Add model exports to __init__.py

This preserves the existing List Platforms functionality while correctly
handling the Platform Details API response structure.

Fixes cyberark#44
The Import Platform API only returns {"PlatformID": "{PlatformID}"},
so the method should return the platform ID string rather than trying
to fetch platform details. This removes the type mismatch and correctly
reflects what the API actually provides.

Users can call platform() separately if they need platform details.
Use Union[ArkPCloudPlatform, ArkPCloudPlatformDetails] return type with
try/fallback logic to maintain backward compatibility while fixing
Pydantic validation failures for Details API endpoint.

Addresses reviewer feedback on PR cyberark#45.
@ofiriluz ofiriluz merged commit a6d7e2b into cyberark:main Jul 31, 2025
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.

Platform Details API Pydantic validation fails in v2.0.14

2 participants