-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
Bug Report: Service.technologies field doesn't accept None value
Description
The Service model in the Python SDK has a validation error when the Instana API returns null for the technologies field. The model definition requires a List[str], but the API can return null for this field.
Location
File: instana_client/models/service.py
Line: 34
Repository: https://github.com/instana/client-python/blob/main/instana_client/models/service.py#L34
Current Implementation
technologies: List[StrictStr] = Field(description="List of technologies: `Eg:[\"springbootApplicationContainer\"]`")Problem
When calling ApplicationAnalyzeApi.get_traces(), the API returns:
{
"items": [
{
"trace": {
"service": {
"id": "...",
"label": "...",
"technologies": null, // <-- This causes validation error
"types": [],
"snapshotIds": []
}
}
}
]
}This results in a Pydantic validation error:
pydantic_core._pydantic_core.ValidationError: 1 validation error for Service
technologies
Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
Expected Behavior
The technologies field should accept None values since the API can return null.
Proposed Fix
Change line 34 in service.py from:
technologies: List[StrictStr] = Field(description="List of technologies: `Eg:[\"springbootApplicationContainer\"]`")To:
technologies: Optional[List[StrictStr]] = Field(default=None, description="List of technologies: `Eg:[\"springbootApplicationContainer\"]`")Reproduction Steps
1. Verify API returns null for technologies field
# Set your Instana credentials
export INSTANA_BASE_URL="https://your-tenant.instana.io"
export INSTANA_API_TOKEN="your-api-token"
# Call the API directly
curl -X POST "${INSTANA_BASE_URL}/api/application-monitoring/analyze/traces" \
-H "Authorization: apiToken ${INSTANA_API_TOKEN}" \
-H "Content-Type: application/json" \
-d '{"pagination": {"retrievalSize": 1}}' \
| jq '.items[0].trace.service | {id, label, technologies, types}'Expected output:
{
"id": "fdf10867224d2bc8915b021527cec356c46fe78e",
"label": "your-service-name",
"technologies": null,
"types": []
}This proves the API returns null for the technologies field.
2. Try to use the SDK
from instana_client.api.application_analyze_api import ApplicationAnalyzeApi
from instana_client.configuration import Configuration
from instana_client.api_client import ApiClient
from instana_client.models.get_traces import GetTraces
import os
config = Configuration()
config.host = os.getenv('INSTANA_BASE_URL')
config.api_key['ApiKeyAuth'] = os.getenv('INSTANA_API_TOKEN')
config.api_key_prefix['ApiKeyAuth'] = 'apiToken'
api_client = ApiClient(config)
api = ApplicationAnalyzeApi(api_client)
# This will fail with Pydantic validation error
result = api.get_traces(get_traces=GetTraces())Error:
pydantic_core._pydantic_core.ValidationError: 1 validation error for Service
technologies
Input should be a valid list [type=list_type, input_value=None, input_type=NoneType]
Environment
- SDK Version: 1.309.1268 (based on OpenAPI Generator output)
- Python Version: 3.13
- Pydantic Version: 2.x
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels