{"record":{"id":"cbbaf85369faf4c3","repo":"prestodb/presto","slug":"owner-cannot-be-present-with-runasinvoker","errorCode":null,"errorMessage":"owner cannot be present with runAsInvoker","messagePattern":"owner cannot be present with runAsInvoker","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-spi/src/main/java/com/facebook/presto/spi/analyzer/ViewDefinition.java","lineNumber":51,"sourceCode":"    private final boolean runAsInvoker;\n\n    @JsonCreator\n    public ViewDefinition(\n            @JsonProperty(\"originalSql\") String originalSql,\n            @JsonProperty(\"catalog\") Optional<String> catalog,\n            @JsonProperty(\"schema\") Optional<String> schema,\n            @JsonProperty(\"columns\") List<ViewColumn> columns,\n            @JsonProperty(\"owner\") Optional<String> owner,\n            @JsonProperty(\"runAsInvoker\") boolean runAsInvoker)\n    {\n        this.originalSql = requireNonNull(originalSql, \"originalSql is null\");\n        this.catalog = requireNonNull(catalog, \"catalog is null\");\n        this.schema = requireNonNull(schema, \"schema is null\");\n        this.columns = unmodifiableList(requireNonNull(columns, \"columns is null\"));\n        this.owner = requireNonNull(owner, \"owner is null\");\n        this.runAsInvoker = runAsInvoker;\n        if (runAsInvoker && owner.isPresent()) {\n            throw new IllegalArgumentException(\"owner cannot be present with runAsInvoker\");\n        }\n    }\n\n    @JsonProperty\n    public String getOriginalSql()\n    {\n        return originalSql;\n    }\n\n    @JsonProperty\n    public Optional<String> getCatalog()\n    {\n        return catalog;\n    }\n\n    @JsonProperty\n    public Optional<String> getSchema()\n    {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spi/src/main/java/com/facebook/presto/spi/analyzer/ViewDefinition.java#L33-L69","documentation":"ViewDefinition describes a view's definition including its owner and runAsInvoker semantics. The constructor enforces an invariant: runAsInvoker=true means the view always runs with the invoking user's identity, so an owner must not also be present; otherwise IllegalArgumentException(\"owner cannot be present with runAsInvoker\") is thrown.","triggerScenarios":"Constructing ViewDefinition (or deserializing its JSON/Thrift form) with owner=Optional.of(...) and runAsInvoker=true.","commonSituations":"Programmatic view migration tools that preserve the original owner while also setting runAsInvoker; hand-edited view definition JSON; connectors constructing ViewDefinition without clearing owner when switching to invoker semantics.","solutions":["Set owner to Optional.empty() when runAsInvoker is true","Set runAsInvoker=false if the view should keep its owner's privileges","Sanitize deserialized view definitions before constructing ViewDefinition"],"exampleFix":"// before\nnew ViewDefinition(originalSql, catalog, schema, columns, Optional.of(owner), true, ...);\n// after\nnew ViewDefinition(originalSql, catalog, schema, columns, Optional.empty(), true, ...);","handlingStrategy":"validation","validationCode":"if (runAsInvoker) owner = Optional.empty();","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize ViewDefinition construction in one helper enforcing the owner/runAsInvoker invariant","Sanitize view definition JSON on import/migration before constructing the object"],"tags":["spi","illegal-argument","view-definition","invariant-violation"],"backgroundTag":"invalid-option-combination","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}