apache / apache/texera

Autofill required-ness is read from the root schema, not the property's own level

Open
#7,826 2 comments 0 reactions 1 assignee Claimed by @anthonychengit View on GitHub
Dominant language
Scala
Stars
314
Forks
187
Avg merge
1d 21h
Merged PRs (30d)
214

Description

### Describe the bug

`WorkflowCompilingService.setOperatorInputAttrs` → `getAttrNames` (`workflow-compiling.service.ts`, around line 362) decides whether an autofilled property is required by consulting the **root** schema:

```ts
operatorSchema.jsonSchema.required?.includes(attrName)
```

But `DynamicSchemaService.mutateProperty` recurses into nested `properties` / `items` / `definitions` (`dynamic-schema.service.ts:181`, `:188`, `:203`), and its callbacks only received `(propertyName, propertyValue)` — the owning object schema was never passed down. So a property nested inside a list element is tested against the root's `required` array, which does not describe it.

**Concrete production case:** `SortOpDesc` + `SortCriteriaUnit`. The root requires `attributes`; each element declares `@JsonProperty(value = "attribute", required = true)` with `@AutofillAttributeName`. Root `required` is `["attributes"]`, so `"attribute"` is not found there and an empty option is appended — offering a blank sort key that `SortOpDesc.generatePythonCode` then rejects at code-generation time (`require(attributes.forall(...))`) rather than at form validation.

The mirror case is the `aggregations[].attribute` shape, where `attribute` is legitimately optional per element (a COUNT(*) needs no column): a root-level required property sharing that name would silently strip its empty option.

Note this also affects the `$ref` + `definitions` path, which is the shape the metadata generator actually emits — `OperatorMetadataGenerator.texeraSchemaGeneratorConfig` on mbknor-jackson-jsonSchema places nested types under root `definitions`.

### How to reproduce?

Open a Sort operator's property editor: the autofilled `attribute` on each sort criterion offers a blank option even though it is declared `required = true`.

### Version/Branch

main

### Task Type

- [ ] Refactor / Cleanup
- [ ] DevOps / Deployment / CI
- [ ] Testing / QA
- [ ] Documentation
- [ ] Performance
- [x] Other

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.