feat: add discoverable asset fieldsets - #1
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the SDK’s asset search behavior to default to a compact, discoverable sparse fieldset (instead of fields=*) to significantly reduce payload size and latency, while exposing typed enums for supported asset fields/relationships and documenting field-selection patterns for consumers.
Changes:
- Default
AssetsClient.search()to a compact fieldset (asset.name,asset.asset_type,asset.status) and add field/relationship enums plus serialization support. - Add a drift-check script +
just check-asset-fieldsrecipe, and expand formatting/linting to includescripts/. - Update consumer-facing docs and metadata (README, changelog, repository URLs) to reflect the new behavior and project location.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_assets_resource.py | Updates expectations for the new default fieldset and adds coverage for enum/list-based field serialization and explicit full fieldsets. |
| src/corva_api_client/resources/assets.py | Introduces field/relationship enums, default compact fieldset, and serialization logic for fields in asset search. |
| src/corva_api_client/resources/init.py | Re-exports new asset field/relationship enums and defaults for public consumption. |
| scripts/check_asset_fields.py | Adds a script to compare SDK enums against Rails serializers/relationship whitelist to detect drift. |
| README.md | Documents the new default asset fieldset and how to select additional fields/relationships safely. |
| pyproject.toml | Updates project URLs to the corva-ai/python-api-client repository. |
| justfile | Includes scripts/ in ruff commands and adds check-asset-fields recipe. |
| CHANGELOG.md | Records the behavioral change and the introduction of discoverable field enums. |
| .github/workflows/ci.yml | Updates CI quality checks to include scripts/ in ruff formatting/linting. |
Suppressed comments (1)
scripts/check_asset_fields.py:45
- _asset_relationships() uses chained split(...)[1] indexing; if the controller layout changes (missing "def show", different ordering, etc.) this will raise IndexError with a non-actionable message. Convert this into a guarded parse that raises a clear ValueError, and read the controller using an explicit UTF-8 encoding.
def _asset_relationships(path: Path) -> set[str]:
source = path.read_text()
index_action = source.split("def index", maxsplit=1)[1].split("def show", maxsplit=1)[0]
serializer_call = index_action.split("serializer_options", maxsplit=1)[1]
match = re.search(r"%i\[([^]]+)]", serializer_call, flags=re.DOTALL)
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
corva-ai/python-api-clientrepositoryfields=*asset search with a compact summary fieldset*,all, and server-default behaviorjust check-asset-fieldsto detect drift from the Rails serializers and relationship whitelistPayload measurement
For 100 otherwise identical production asset results:
*The compact response was 96.8% smaller (approximately 31x). Timings are a single observational sample and may vary.
Validation
just checkjust check-distjust check-asset-fields /Users/bryanray/Projects/Work/Corva/corva-apiBehavioral change
Asset search now defaults to
asset.name,asset.asset_type,asset.status. Callers that require the previous full response can passfields="*"explicitly.