Skip to content

Commit 06fda33

Browse files
committed
Fix specs
1 parent 3545e33 commit 06fda33

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

dev/specs/infp-504-artifact-composition/contracts/filter-interfaces.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async def artifact_content(storage_id: str) -> str
1919
| Permission denied (401/403) || `JinjaFilterError("artifact_content", "permission denied for storage_id: {id}")` |
2020
| No client provided || `JinjaFilterError("artifact_content", "requires InfrahubClient", hint="pass client via Jinja2Template(client=...)")` |
2121

22-
**Validation**: Blocked in `CORE` context. Allowed in `WORKER` context.
22+
**Validation**: Blocked in `CORE` context. Allowed in `WORKER` and `LOCAL` contexts.
2323

2424
### file_object_content
2525

@@ -37,7 +37,7 @@ async def file_object_content(storage_id: str) -> str
3737
| Permission denied (401/403) || `JinjaFilterError("file_object_content", "permission denied for storage_id: {id}")` |
3838
| No client provided || `JinjaFilterError("file_object_content", "requires InfrahubClient", hint="pass client via Jinja2Template(client=...)")` |
3939

40-
**Validation**: Blocked in `CORE` context. Allowed in `WORKER` context.
40+
**Validation**: Blocked in `CORE` context. Allowed in `WORKER` and `LOCAL` contexts.
4141

4242
### from_json
4343

dev/specs/infp-504-artifact-composition/data-model.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,9 @@ async def get_file_by_storage_id(self, storage_id: str, tracker: str | None = No
152152
```python
153153
# In AVAILABLE_FILTERS:
154154

155-
# Infrahub client-dependent filters (worker context only)
156-
FilterDefinition("artifact_content", allowed_contexts=ExecutionContext.WORKER, source="infrahub"),
157-
FilterDefinition("file_object_content", allowed_contexts=ExecutionContext.WORKER, source="infrahub"),
155+
# Infrahub client-dependent filters (worker and local contexts)
156+
FilterDefinition("artifact_content", allowed_contexts=ExecutionContext.WORKER | ExecutionContext.LOCAL, source="infrahub"),
157+
FilterDefinition("file_object_content", allowed_contexts=ExecutionContext.WORKER | ExecutionContext.LOCAL, source="infrahub"),
158158

159159
# Parsing filters (trusted, all contexts)
160160
FilterDefinition("from_json", allowed_contexts=ExecutionContext.ALL, source="infrahub"),

dev/specs/infp-504-artifact-composition/spec.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ The existing single `restricted: bool` parameter on `validate()` is insufficient
9999
- **FR-004**: The system MUST provide a `file_object_content` Jinja2 filter that accepts a `storage_id` string and returns the raw string content of the referenced file object, using the file-object-specific API path or metadata handling — this implementation is distinct from `artifact_content`.
100100
- **FR-005**: Both `artifact_content` and `file_object_content` MUST raise `JinjaFilterError` when the input `storage_id` is null or empty, or when the object store cannot retrieve the content for any reason (not found, network failure, auth failure). Additionally, `file_object_content` MUST raise `JinjaFilterError` when the retrieved content has a non-text content type (i.e., not `text/*`, `application/json`, or `application/yaml`).
101101
- **FR-006**: Both `artifact_content` and `file_object_content` MUST raise `JinjaFilterError` when invoked and no `InfrahubClient` was supplied to `Jinja2Template` at construction time. The error message MUST name the filter and explain that an `InfrahubClient` is required.
102-
- **FR-007**: Both `artifact_content` and `file_object_content` MUST be registered with `allowed_contexts=ExecutionContext.WORKER` in the `FilterDefinition` registry. The `validate()` method accepts an `ExecutionContext` flag; these filters are blocked in the `CORE` context (API server computed attributes) and permitted in the `WORKER` context (Prefect workers, where an `InfrahubClient` is available). Within Infrahub, any Jinja2-based computed attributes that use these new filters should cause a schema violation when loading the schema.
102+
- **FR-007**: Both `artifact_content` and `file_object_content` MUST be registered with `allowed_contexts=ExecutionContext.WORKER | ExecutionContext.LOCAL` in the `FilterDefinition` registry. The `validate()` method accepts an `ExecutionContext` flag; these filters are blocked in the `CORE` context (API server computed attributes) and permitted in the `WORKER` context (Prefect workers) and `LOCAL` context (CLI/unrestricted rendering). Within Infrahub, any Jinja2-based computed attributes that use these new filters should cause a schema violation when loading the schema.
103103
- **FR-008**: The system MUST provide `from_json` and `from_yaml` Jinja2 filters (adding them only if not already present in the environment) that parse a string into a Python dict/list. Applying them to an empty string MUST return an empty dict without raising. Applying them to malformed content MUST raise `JinjaFilterError`.
104104
- **FR-009**: `from_json` and `from_yaml` MUST be registered as trusted filters (`trusted=True`) since they perform no external I/O.
105105
- **FR-010**: All new filters MUST work correctly with `InfrahubClient` (async). `InfrahubClientSync` is not a supported client type for `Jinja2Template`. Both the sandboxed environment (string-based templates) and the file-based environment MUST have `enable_async=True` to support async filter callables via Jinja2's `auto_await`.

0 commit comments

Comments
 (0)