coding-client 1.21.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- coding_client/__init__.py +1 -0
- coding_client/api/__init__.py +19 -0
- coding_client/api/exception_handlers.py +158 -0
- coding_client/api/logging_setup.py +44 -0
- coding_client/api/metrics.py +40 -0
- coding_client/api/openapi_config.py +124 -0
- coding_client/api/request_logging.py +60 -0
- coding_client/api/validation.py +150 -0
- coding_client/auth/__init__.py +78 -0
- coding_client/auth/_default_tenant.py +132 -0
- coding_client/auth/_header_trust.py +98 -0
- coding_client/auth/_onbehalf.py +315 -0
- coding_client/auth/_trusted_networks.py +94 -0
- coding_client/auth/dependencies.py +61 -0
- coding_client/auth/middleware.py +445 -0
- coding_client/auth/models.py +83 -0
- coding_client/auth/outbound.py +137 -0
- coding_client/auth/rbac.py +21 -0
- coding_client/auth/rbac_coding.py +5 -0
- coding_client/auth/tenant.py +650 -0
- coding_client/auth/websocket.py +148 -0
- coding_client/clients/__init__.py +24 -0
- coding_client/clients/base.py +131 -0
- coding_client/clients/coding_ai.py +33 -0
- coding_client/clients/coding_analysis.py +36 -0
- coding_client/clients/coding_containers.py +45 -0
- coding_client/clients/coding_github.py +127 -0
- coding_client/clients/coding_realtime.py +127 -0
- coding_client/clients/coding_security.py +51 -0
- coding_client/clients/coding_testing.py +31 -0
- coding_client/clients/coding_workspaces.py +265 -0
- coding_client/config/__init__.py +12 -0
- coding_client/config/base_settings.py +61 -0
- coding_client/config/yaml_config_loader.py +172 -0
- coding_client/db/__init__.py +42 -0
- coding_client/db/db_types.py +122 -0
- coding_client/db/exceptions.py +59 -0
- coding_client/db/postgres_connection.py +572 -0
- coding_client/db/tenant_query_helper.py +417 -0
- coding_client/db_init.py +49 -0
- coding_client/exceptions/__init__.py +67 -0
- coding_client/exceptions/api_exceptions.py +395 -0
- coding_client/exceptions/pydantic_ai_exceptions.py +533 -0
- coding_client/interfaces/__init__.py +22 -0
- coding_client/interfaces/cache_interface.py +179 -0
- coding_client/interfaces/container_interface.py +49 -0
- coding_client/interfaces/docker_interface.py +283 -0
- coding_client/interfaces/graph_interface.py +28 -0
- coding_client/interfaces/security_interface.py +72 -0
- coding_client/interfaces/webhook_interface.py +67 -0
- coding_client/llm/__init__.py +54 -0
- coding_client/llm/base_agent.py +195 -0
- coding_client/llm/context.py +121 -0
- coding_client/llm/responses.py +102 -0
- coding_client/llm/routing.py +82 -0
- coding_client/llm/settings.py +102 -0
- coding_client/models/__init__.py +62 -0
- coding_client/models/agent.py +38 -0
- coding_client/models/ai_test_failure.py +745 -0
- coding_client/models/analysis.py +330 -0
- coding_client/models/architecture.py +685 -0
- coding_client/models/bug.py +128 -0
- coding_client/models/code_graph.py +317 -0
- coding_client/models/container.py +241 -0
- coding_client/models/core.py +878 -0
- coding_client/models/docker_container.py +104 -0
- coding_client/models/github.py +293 -0
- coding_client/models/logging.py +29 -0
- coding_client/models/package_manager.py +257 -0
- coding_client/models/pr_validation.py +440 -0
- coding_client/models/pydantic_ai.py +395 -0
- coding_client/models/repo_scanner.py +249 -0
- coding_client/models/responses.py +431 -0
- coding_client/models/security.py +185 -0
- coding_client/models/static_analysis.py +508 -0
- coding_client/models/system.py +48 -0
- coding_client/models/test_executor.py +204 -0
- coding_client/models/testing.py +673 -0
- coding_client/models/testing_config.py +200 -0
- coding_client/models/validation.py +127 -0
- coding_client/models_init.py +272 -0
- coding_client/telemetry.py +195 -0
- coding_client/testing.py +180 -0
- coding_client/types/__init__.py +130 -0
- coding_client/types/constraint_types.py +276 -0
- coding_client/types/core_types.py +112 -0
- coding_client/types/state_machine.py +443 -0
- coding_client/utils/__init__.py +86 -0
- coding_client/utils/archive_utils.py +387 -0
- coding_client/utils/ast_debug.py +45 -0
- coding_client/utils/async_timeout.py +364 -0
- coding_client/utils/constants.py +518 -0
- coding_client/utils/content_processing.py +326 -0
- coding_client/utils/database.py +916 -0
- coding_client/utils/encoding_helper.py +222 -0
- coding_client/utils/enum_helpers.py +166 -0
- coding_client/utils/file_operations.py +177 -0
- coding_client/utils/filesystem_ops.py +528 -0
- coding_client/utils/http_client.py +562 -0
- coding_client/utils/path_utils.py +471 -0
- coding_client/utils/profiling.py +421 -0
- coding_client/utils/response_builder.py +240 -0
- coding_client/utils/retry_helper.py +712 -0
- coding_client/utils/security_validation.py +423 -0
- coding_client-1.21.2.dist-info/METADATA +234 -0
- coding_client-1.21.2.dist-info/RECORD +109 -0
- coding_client-1.21.2.dist-info/WHEEL +5 -0
- coding_client-1.21.2.dist-info/licenses/LICENSE +201 -0
- coding_client-1.21.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"""Test executor validation models for multi-language code validation.
|
|
2
|
+
|
|
3
|
+
This module provides Pydantic models for the test executor validation endpoints,
|
|
4
|
+
ensuring consistent request/response structures across all supported programming
|
|
5
|
+
languages. The models are designed with Pydantic v2/v3 compatibility and support
|
|
6
|
+
validation for Python, JavaScript, TypeScript, Java, Rust, C#, and Go.
|
|
7
|
+
|
|
8
|
+
The validation system uses these models to:
|
|
9
|
+
- Accept code validation requests with language-specific options
|
|
10
|
+
- Provide consistent validation responses across different languages
|
|
11
|
+
- Handle errors gracefully with detailed error information
|
|
12
|
+
- Support language-specific features like class names, project types, etc.
|
|
13
|
+
|
|
14
|
+
Classes:
|
|
15
|
+
CodeValidationRequest: Base request model for code validation with language options
|
|
16
|
+
CodeValidationResponse: Standardized response with validation results
|
|
17
|
+
ValidationErrorResponse: Error response model for validation failures
|
|
18
|
+
|
|
19
|
+
Functions:
|
|
20
|
+
validate_code_size: Check if code size is within acceptable limits
|
|
21
|
+
sanitize_error_output: Clean and truncate error messages for safe output
|
|
22
|
+
|
|
23
|
+
Example:
|
|
24
|
+
```python
|
|
25
|
+
from test_executor_models import CodeValidationRequest, CodeValidationResponse
|
|
26
|
+
|
|
27
|
+
# Create a validation request
|
|
28
|
+
request = CodeValidationRequest(
|
|
29
|
+
code='console.log("Hello, World!");',
|
|
30
|
+
filename="test.js",
|
|
31
|
+
language_version="ES2022",
|
|
32
|
+
strict_mode=True
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
# Process validation response
|
|
36
|
+
response = CodeValidationResponse(
|
|
37
|
+
validation_id="val-123",
|
|
38
|
+
valid=True,
|
|
39
|
+
errors=[],
|
|
40
|
+
warnings=["Missing semicolon"],
|
|
41
|
+
output="Code is syntactically valid",
|
|
42
|
+
metadata={"ast_nodes": 5}
|
|
43
|
+
)
|
|
44
|
+
```
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
from typing import Any
|
|
48
|
+
|
|
49
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class CodeValidationRequest(BaseModel):
|
|
53
|
+
"""Request model for code validation endpoints."""
|
|
54
|
+
|
|
55
|
+
model_config = ConfigDict(
|
|
56
|
+
str_strip_whitespace=False, # Preserve code formatting
|
|
57
|
+
validate_default=True,
|
|
58
|
+
use_enum_values=True,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
code: str = Field(
|
|
62
|
+
...,
|
|
63
|
+
description="Source code to validate",
|
|
64
|
+
min_length=0, # Allow empty code but require the field
|
|
65
|
+
max_length=1_000_000, # 1MB limit
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
filename: str | None = Field(
|
|
69
|
+
default=None,
|
|
70
|
+
description="Optional filename for context-aware validation",
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
# Language-specific options
|
|
74
|
+
class_name: str | None = Field(
|
|
75
|
+
default=None,
|
|
76
|
+
alias="className",
|
|
77
|
+
description="Class name for Java/C# validation",
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
project_type: str | None = Field(
|
|
81
|
+
default=None,
|
|
82
|
+
alias="projectType",
|
|
83
|
+
description="Project type for C# validation",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
language_version: str | None = Field(
|
|
87
|
+
default=None,
|
|
88
|
+
alias="languageVersion",
|
|
89
|
+
description="Language version for validation",
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
strict_mode: bool | None = Field(
|
|
93
|
+
default=False,
|
|
94
|
+
alias="strictMode",
|
|
95
|
+
description="Enable strict validation rules",
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class CodeValidationResponse(BaseModel):
|
|
100
|
+
"""Response model for code validation endpoints."""
|
|
101
|
+
|
|
102
|
+
model_config = ConfigDict(populate_by_name=True, use_enum_values=True)
|
|
103
|
+
|
|
104
|
+
validation_id: str = Field(
|
|
105
|
+
..., alias="validationId", description="Unique validation request ID"
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
valid: bool = Field(..., description="Whether the code is syntactically valid")
|
|
109
|
+
|
|
110
|
+
errors: list[str] = Field(default_factory=list, description="List of validation errors")
|
|
111
|
+
|
|
112
|
+
warnings: list[str] | None = Field(default=None, description="Optional list of warnings")
|
|
113
|
+
|
|
114
|
+
output: str = Field(default="", description="Additional validation output")
|
|
115
|
+
|
|
116
|
+
metadata: dict[str, Any] | None = Field(default=None, description="Language-specific metadata")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
class TestExecutorValidationError(BaseModel):
|
|
120
|
+
"""Error response model for validation failures."""
|
|
121
|
+
|
|
122
|
+
model_config = ConfigDict(populate_by_name=True)
|
|
123
|
+
|
|
124
|
+
validation_id: str | None = Field(
|
|
125
|
+
default=None,
|
|
126
|
+
alias="validationId",
|
|
127
|
+
description="Validation ID if available",
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
error: str = Field(..., description="Error message")
|
|
131
|
+
|
|
132
|
+
details: str | None = Field(default=None, description="Detailed error information")
|
|
133
|
+
|
|
134
|
+
code: int | None = Field(default=None, description="Error code")
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
# Validation utility functions
|
|
138
|
+
def validate_code_size(code: str, max_size: int = 1_000_000) -> bool:
|
|
139
|
+
"""Validate that code size is within acceptable limits.
|
|
140
|
+
|
|
141
|
+
Checks if the UTF-8 encoded size of the code string is within the specified
|
|
142
|
+
maximum size limit. This prevents processing of excessively large code files
|
|
143
|
+
that could cause memory or performance issues.
|
|
144
|
+
|
|
145
|
+
Args:
|
|
146
|
+
code (str): Source code string to validate.
|
|
147
|
+
max_size (int, optional): Maximum allowed size in bytes. Defaults to 1MB (1_000_000).
|
|
148
|
+
|
|
149
|
+
Returns:
|
|
150
|
+
bool: True if code size is within limits, False otherwise.
|
|
151
|
+
|
|
152
|
+
Example:
|
|
153
|
+
```python
|
|
154
|
+
code = "def hello():\\n print('Hello, World!')"
|
|
155
|
+
if validate_code_size(code):
|
|
156
|
+
# Process the code
|
|
157
|
+
pass
|
|
158
|
+
else:
|
|
159
|
+
# Reject as too large
|
|
160
|
+
raise ValueError("Code exceeds maximum size limit")
|
|
161
|
+
```
|
|
162
|
+
"""
|
|
163
|
+
return len(code.encode("utf-8")) <= max_size
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def sanitize_error_output(error: str, max_length: int = 1000) -> str:
|
|
167
|
+
"""Sanitize and truncate error messages for safe output.
|
|
168
|
+
|
|
169
|
+
Removes sensitive file paths and truncates long error messages to prevent
|
|
170
|
+
information leakage and ensure consistent response sizes. This function
|
|
171
|
+
strips out internal container paths that might reveal system structure.
|
|
172
|
+
|
|
173
|
+
Args:
|
|
174
|
+
error (str): Raw error message to sanitize.
|
|
175
|
+
max_length (int, optional): Maximum length for output. Defaults to 1000.
|
|
176
|
+
|
|
177
|
+
Returns:
|
|
178
|
+
str: Sanitized error message with sensitive paths removed and length limited.
|
|
179
|
+
|
|
180
|
+
Example:
|
|
181
|
+
```python
|
|
182
|
+
raw_error = "Error in /app/test_workspace/secret_file.py: syntax error"
|
|
183
|
+
clean_error = sanitize_error_output(raw_error)
|
|
184
|
+
# Returns: "Error in secret_file.py: syntax error"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
Note:
|
|
188
|
+
The function specifically removes:
|
|
189
|
+
- /app/test_workspace/ paths (internal container structure)
|
|
190
|
+
- /tmp/ paths (temporary file locations)
|
|
191
|
+
- Truncates with "..." if message exceeds max_length
|
|
192
|
+
"""
|
|
193
|
+
if not error:
|
|
194
|
+
return ""
|
|
195
|
+
|
|
196
|
+
# Remove sensitive paths
|
|
197
|
+
error = error.replace("/app/test_workspace/", "")
|
|
198
|
+
error = error.replace("/tmp/", "") # nosec B108 — sanitizes path text out of an error string; not temp-file creation
|
|
199
|
+
|
|
200
|
+
# Truncate if too long
|
|
201
|
+
if len(error) > max_length:
|
|
202
|
+
error = error[: max_length - 3] + "..."
|
|
203
|
+
|
|
204
|
+
return error
|