Repository navigation
feat(policy-agent): Revoke as accessType enum in databasePolicyConfig - #29392
harshsoni2024 merged 3 commits into
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
✅ TypeScript Types Auto-UpdatedThe generated TypeScript types have been automatically updated based on JSON schema changes in this PR. |
| "type": "string", | ||
| "javaType": "org.openmetadata.schema.metadataIngestion.policyagentconfig.DatabaseAccessType", | ||
| "enum": ["FullAccess", "ColumnLevel", "Masked"] | ||
| "enum": ["FullAccess", "ColumnLevel", "Masked", "Revoke"] |
There was a problem hiding this comment.
⚠️ Edge Case: requestedAccess still required when accessType is Revoke
This PR moves "Revoke" out of the requestedAccess enum and into the accessType enum, so revocation is now expressed as accessType = "Revoke". However, requestedAccess remains in the top-level required array (line 74). As a result, any caller issuing a revoke must still supply one of Read/Write/Admin, a permission level that has no meaning in a revoke context. Previously revocation was encoded as requestedAccess = "Revoke", which avoided this contradiction.
This forces callers (and the generated TS type requestedAccess: RequestedAccess) to send a semantically meaningless value, and there is no longer any way to validate that a revoke request omits an irrelevant permission level. Consider either dropping requestedAccess from the global required list, or adding a JSON Schema conditional so it is required only when accessType is not "Revoke". Remember to re-run make generate after editing the schema so the generated TS/Java types stay in sync.
Require requestedAccess only when accessType is not Revoke via an if/then conditional.:
"required": ["principal", "databaseName", "accessType"],
"if": {
"not": { "properties": { "accessType": { "const": "Revoke" } } }
},
"then": {
"required": ["requestedAccess"]
},
"dependencies": {
"tableName": ["schemaName"],
"columnName": ["tableName"]
},
Was this helpful? React with 👍 / 👎
🔴 Playwright Results — 3 failure(s), 17 flaky✅ 4450 passed · ❌ 3 failed · 🟡 17 flaky · ⏭️ 88 skipped
Genuine Failures (failed on all attempts)❌
|
…e_access_accessType
bfe5d3c
into
policy_agent_revoke_access_oss
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Gitar
|
|
…s enum (#29267) * feat(policy-agent): add Revoke to databasePolicyConfig requestedAccess enum Add a "Revoke" value to the requestedAccess enum in databasePolicyConfig so a Data Access Request can ask the policy agent to remove access, not just grant it. The connector-side handling (Snowflake) lives in the Collate repo. Co-Authored-By: Claude Opus 4.8 <[email protected]> * Update generated TypeScript types * feat(policy-agent): Revoke as accessType enum in databasePolicyConfig (#29392) * feat(governance): add accessType override to policyAgentTaskDefinition Lets a PolicyAgent workflow node force the accessType sent to the agent (FullAccess/ColumnLevel/Masked/Revoke) regardless of the request payload, so the DAR revoke path can route through the agent with accessType=Revoke while preserving the original requestedAccess level (Read/Write/Admin) from the payload — the connector then tears down the same level the requester originally received. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Update generated TypeScript types * refactor(governance): $ref shared accessType enum in policyAgentTaskDefinition The accessType override on policyAgentTaskDefinition was duplicating the [FullAccess, ColumnLevel, Masked, Revoke] enum literal that already lives on databasePolicyConfig#/definitions/accessType. Two independent literals silently drift the moment one side adds or removes a value. Replace the inline type + enum with a $ref to the shared definition so the override always tracks the policy-config enum. The generated PolicyAgentTaskDefinition.Config.getAccessType() now returns the same DatabaseAccessType used elsewhere; callers only ever read .value() on it so the binding change is source-compatible. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Update generated TypeScript types * feat(governance): user-task expiry timer + Expired task status (#29596) * feat(governance): user-task expiry timer with Expired status Add a Flowable boundary-timer mechanism that lets a workflow author auto-fire a user task after an ISO 8601 duration elapses, optionally closing the underlying Task entity with a configurable resolutionType. Schema (additive): - userApprovalTask.json: new optional config.expiryTimer { durationVariable, transitionId, closeAsResolution? }. durationVariable names the process variable whose value Flowable evaluates as the ISO 8601 timer duration; transitionId is written into the node result variable so the outer workflow edge with that condition routes downstream; closeAsResolution, when set, makes ExpireOnTimerImpl resolve the OM Task with that resolutionType (TaskRepository.mapResolutionToStatus maps to the matching status — TimedOut → Expired). - task.json: add Expired to taskStatus enum so the TimedOut → Expired mapping surfaces a dedicated terminal status (no more overloading Failed). Engine wiring: - UserApprovalTask.attachExpiryTimerIfConfigured attaches an interrupting BoundaryEvent with TimerEventDefinition("${<durationVariable>}") to the user-task; on fire it routes through a service task (ExpireOnTimerImpl) into the subprocess endEvent, so the outer workflow picks the matching condition. - ExpireOnTimerImpl writes node.result = transitionId and, if resolutionTypeExpr is set, calls TaskRepository.resolveTask with that resolution. The OM Task close is wrapped in a try/catch so the BPMN flow always advances even if the resolve call fails. Mapping change: - TaskRepository.mapResolutionToStatus: TimedOut → Expired (was Failed). TimedOut had no callers in OSS before this PR; the new mapping reflects the semantic that "task ran out of time" deserves its own status rather than reading as a system failure. - TaskWorkflowHandler switch on getTargetTaskStatus updated to cover Expired alongside Failed (both map back to TimedOut on the reverse path). Scale: per-task cost is one ACT_RU_TIMER_JOB row; engine-wide acquisition loop (timerJobAcquisitionInterval, default 5s) handles dispatch — no per-task polling. Crash-safe and multi-replica safe via Flowable's standard LOCK_OWNER atomic acquire. Generic — not DAR-specific. Any workflow that wires expiryTimer onto a userApprovalTask inherits the timer + auto-resolve behavior. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Update generated TypeScript types * fix(governance): expiry-timer review fixes (gitar + greptile) Address review feedback on the user-task expiry timer: 1) gitar #2 + Failed status reachability — add Expired to TaskResolutionType enum (was missing) and split the reverse mapping so Failed stays reachable via TaskResolutionType.TimedOut (TimedOut → Failed, restored) while Expired gets its own resolutionType (Expired → Expired). Prior version collapsed both onto TimedOut, silently rewriting any workflow that used targetTaskStatus=Failed. Now Failed and Expired are independent statuses each reachable via their matching resolutionType, no behavior change for existing workflows. 2) gitar #1 + greptile P2 — ExpireOnTimerImpl now skips resolveTask when the task is already in a terminal status. Prevents the race where the user resolves the task via API while the timer-job acquisition loop has already picked up the boundary timer in a separate transaction (would otherwise overwrite Completed/Approved/Revoked with Expired and fire postUpdate hooks twice — IncidentTcrsSyncHandler etc. can't assume same-status transitions are idempotent). 3) greptile P1 — wrap UUID.fromString inside the try-catch in ExpireOnTimerImpl. A malformed taskEntityId would otherwise throw IllegalArgumentException out of execute(), causing Flowable to retry + dead-letter the timer job, leaving the workflow instance stuck. Now logs + lets BPMN flow advance. 4) DAR form schema requires `duration` — boundary timer expression ${accessDuration} would throw at user-task entry if no duration was supplied on the DAR payload, rolling back task entry. Making duration required at the form-schema layer rejects such DARs at the API edge instead of letting them break the workflow downstream. Pairs with the parseability validation on the Collate side (RunAllPolicyAgentsDelegate.isValidIso8601Duration). 5) TaskWorkflowHandler + TaskWorkflowLifecycleResolver — exhaustive switch over TaskResolutionType updated to cover the new Expired case (defaults to "expired" transition id). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Update generated TypeScript types * fix(governance): expiry close must fetch full task or it erases comments gitar-bot #4 (re-scan finding): ExpireOnTimer.resolveTaskExpired loaded the Task with the narrow field set "assignees,reviewers,about,createdBy,payload, resolution", omitting comments. TaskRepository.clearFields sets comments=null when the field is not requested, and resolveTask -> storeEntity then serializes the in-memory Task back via JsonUtils.pojoToJson — silently overwriting all existing comments on auto-close. Every other resolveTask caller in OSS loads getFields("*") (or explicitly includes comments) for exactly this reason; switch ExpireOnTimer to match. Comments on the task survive the auto-close instead of getting wiped. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(governance): add ManualRevoke status + stop stamping spurious Completed resolution on transitional moves Two related task-lifecycle fixes surfaced while validating the expiry-timer work end-to-end: 1) Add ManualRevoke to TaskEntityStatus. AwaitingRevoke stage in the DAR workflow currently stamps tasks as InProgress, which is semantically wrong — nothing is actively in progress, the task is parked waiting for a human to confirm the manual revoke. ManualRevoke names the substate explicitly so UI badges + reporting can distinguish "in-flight" from "stuck pending human." Additive enum, exhaustive switches in TaskWorkflowHandler updated. 2) Stop auto-stamping resolution.type=Completed on transitional status moves. The updateStatus path in TaskRepository previously stamped a default Completed resolution whenever the new status was outside {Open, InProgress, Pending} — that included Approved and Granted, both transitional substates of an in-flight DAR. Result: tasks at ApprovedAccess showed resolution.type=Completed even though they hadn't actually resolved, leaking into downstream consumers + audit. Replace the narrow 3-status skip list with a shared NON_TERMINAL_STATUSES set / isTerminalStatus helper so a Completed fallback only fires when the status is genuinely terminal (Rejected / Completed / Cancelled / Failed / Revoked / Expired). 3) ExpireOnTimerImpl now uses TaskRepository.NON_TERMINAL_STATUSES instead of its own copy — one source of truth for "is this task still in flight". Generated TS types regenerated for ManualRevoke across the four files that expose TaskStatus. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Update generated TypeScript types * fix(tasks): allow ManualRevoke to be resolved (TaskResource guard + TaskWorkflowHandler fallback) Both task-resolve guards rejected ManualRevoke as "already in status" — they were written for the legacy {Open, InProgress} (+ Approved/Granted for DAR) allow-list. With ManualRevoke as the new status for AwaitingRevoke, the markAsRevoked transition got a 400 even though the user task was active. - TaskResource.validateTaskCanBeResolved: extend the Approved/Granted-with-transitions check to include ManualRevoke. - TaskWorkflowHandler fallback path: use TaskRepository.NON_TERMINAL_STATUSES (one source of truth) instead of the inline {Open, InProgress} check; covers ManualRevoke + Approved + Granted + Pending automatically. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * fix(tasks): bot-nit fixes — drop fully-qualified Set, use isTerminalStatus null-safe helper - TaskRepository.NON_TERMINAL_STATUSES: use imported `Set` (already imported) instead of `java.util.Set` (gitar nit). - TaskWorkflowHandler: route the terminal-status guard through `TaskRepository.isTerminalStatus()` so `task.getStatus()==null` no longer NPEs out of `Set.of(...).contains(null)` (greptile P1). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> --------- Co-authored-by: Claude Opus 4.7 (1M context) <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * fix(tasks,policy-agent): address bot-review findings on PR #29267 Squashed bot-review addressal commit. TaskRepository.java - Single source of truth for non-terminal statuses: NON_TERMINAL_TASK_STATUSES (the canonical List, guarded by CreateTaskTest for DAR duplicate-check) with NON_TERMINAL_STATUSES derived as Set.copyOf(...). The two can't drift. - ManualRevoke added to the list: at ManualRevoke the workflow is parked waiting for a human to confirm the revoke — access is still live at the source, so a new DAR against the same entity must be blocked. CreateTask.java - isTerminalTaskStatus() now treats ManualRevoke as non-terminal, matching TaskRepository. Prevents the divergence bots flagged where the DAR duplicate-check and the workflow-lifecycle predicate disagreed. ListFilter.java - 'active' status group now includes 'ManualRevoke' (still live). - 'closed' status group now includes 'Expired' (terminal auto-expire). TaskWorkflowHandler.java - Dropped fully-qualified `org.openmetadata.service.jdbi3.TaskRepository` at the terminal-status guard; TaskRepository is already imported. CreateTaskTest.java - Added explicit assertions for Expired (terminal) and ManualRevoke (non-terminal) so future status changes can't silently regress the boundary. Schema docs - userApprovalTask.json expiryTimer.closeAsResolution description: was "TimedOut maps to Expired" — actually TimedOut→Failed and Expired→Expired. Corrected to match TaskRepository.mapResolutionToStatus. - UserApprovalTask.java Javadoc: same correction. - policyAgentTaskDefinition.json branches schema: was locked at exactly ["granted","manual","denied"] (min/maxItems=3) which prevented the revoke node from declaring only ["revoked","manual"]. Relaxed to minItems=1 with a description explaining that node authors declare only the branches their delegate actually emits. - policyAgentTaskDefinition.json accessType override description now says revoke strips whatever the principal holds (a revoke takes back everything, not a specific level); requestedAccess is preserved for audit/UI display only. Generated TS types regenerated to match the schema changes. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Update generated TypeScript types * fix(tasks): delegate CreateTask terminal-status to TaskRepository + fail fast on misconfigured expiryTimer Follow-up bot findings on PR #29267 review 4609780598. 1. CreateTask.isTerminalTaskStatus now delegates to TaskRepository.isTerminalStatus. The two hand-rolled predicates had identical membership after the ManualRevoke sync but could silently drift the next time a new TaskEntityStatus is added. Single source of truth is TaskRepository.NON_TERMINAL_TASK_STATUSES. 2. UserApprovalTask.attachExpiryTimerIfConfigured used to silently skip when expiryTimer.durationVariable or transitionId was blank. A workflow author would deploy a broken definition and only find out when a task got stranded at runtime with no timer ever firing. Now throws IllegalArgumentException at parse time so the deploy fails visibly and the JSON gets fixed. Not applied: Copilot's suggestion to treat null as terminal in TaskRepository.isTerminalStatus — the current caller pattern at TaskWorkflowHandler:212 relies on null-status falling through to applyTaskResolution rather than throwing. Flipping the semantic would need a matching caller refactor; deferred. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]> * Add duration payload to task api --------- Co-authored-by: Claude Opus 4.8 <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Ram Narayan Balaji <[email protected]> Co-authored-by: Ram Narayan Balaji <[email protected]> Co-authored-by: Anujkumar Yadav <[email protected]>



Changes
Adds
"Revoke"to theaccessTypeenum inmetadataIngestion/policyagentconfig/databasePolicyConfig.json:Summary by Gitar
RevoketoaccessTypeenum indatabasePolicyConfig.json.RevokefromrequestedAccessenum indatabasePolicyConfig.json.This will update automatically on new commits.
Greptile Summary
This PR reclassifies
"Revoke"from therequestedAccessenum into theaccessTypeenum indatabasePolicyConfig.jsonand regenerates the five corresponding TypeScript files. The intent is to model revocation as an access pattern rather than a permission level."Revoke"removed fromrequestedAccess(["Read","Write","Admin","Revoke"]→["Read","Write","Admin"]) and added toaccessType(["FullAccess","ColumnLevel","Masked"]→["FullAccess","ColumnLevel","Masked","Revoke"]).requestedAccessremains in therequiredarray, so any call withaccessType = "Revoke"must still supply arequestedAccessvalue like"Read"or"Write"— values that are semantically meaningless for a revoke. Consider either droppingrequestedAccessfromrequired, or adding a JSON Schemaif/then/elseconditional that makes it required only whenaccessTypeis not"Revoke"..tsfiles are updated consistently and mirror the schema change correctly.Confidence Score: 4/5
Safe to merge with the caveat that callers performing a Revoke must still supply a
requestedAccessvalue that has no meaningful effect.The schema correctly moves
RevoketoaccessType, butrequestedAccessremains inrequired, forcing every Revoke payload to include a permission level (Read/Write/Admin) that is meaningless in that context. This creates a confusing and error-prone API contract that any consumer of the schema will have to work around.databasePolicyConfig.json— therequiredarray still mandatesrequestedAccesseven for Revoke operations.Important Files Changed
RevokefromrequestedAccessenum toaccessTypeenum, butrequestedAccessremains in therequiredarray, forcing callers to supply a semantically irrelevant value when revoking access.Revokeadded toAccessTypeenum and removed fromRequestedAccessenum, consistent with the JSON schema change.Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[PolicyAgent Request] --> B{accessType} B -->|FullAccess| C[requestedAccess required\nRead / Write / Admin] B -->|ColumnLevel| C B -->|Masked| C B -->|Revoke| D[requestedAccess still required ⚠️\nRead / Write / Admin\nbut semantically irrelevant] C --> E[Grant applied] D --> F[Revoke applied] style D fill:#ffcccc,stroke:#cc0000%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%% flowchart TD A[PolicyAgent Request] --> B{accessType} B -->|FullAccess| C[requestedAccess required\nRead / Write / Admin] B -->|ColumnLevel| C B -->|Masked| C B -->|Revoke| D[requestedAccess still required ⚠️\nRead / Write / Admin\nbut semantically irrelevant] C --> E[Grant applied] D --> F[Revoke applied] style D fill:#ffcccc,stroke:#cc0000Comments Outside Diff (2)
openmetadata-spec/src/main/resources/json/schema/metadataIngestion/policyagentconfig/databasePolicyConfig.json, line 74 (link)requestedAccessis still required whenaccessTypeis"Revoke"requestedAccessremains in therequiredarray, so callers performing a revoke operation must supply a value like"Read"or"Write"that is semantically meaningless in the revoke context. The previous model encoded revocation asrequestedAccess = "Revoke", avoiding this. Consider either removingrequestedAccessfromrequiredglobally, or adding a JSON Schemaif/then/elseconditional so it is only required whenaccessTypeis NOT"Revoke".openmetadata-spec/src/main/resources/json/schema/metadataIngestion/policyagentconfig/databasePolicyConfig.json, line 74 (link)requestedAccessstill required for Revoke operationsrequestedAccessremains in therequiredarray, so any caller settingaccessType = "Revoke"must also supply arequestedAccessvalue ("Read","Write", or"Admin"). These permission levels are semantically meaningless for a revoke operation and create a confusing API contract. Consider either removingrequestedAccessfromrequired, or adding a JSON Schemaif/then/elseconditional that makes it required only whenaccessTypeis not"Revoke".Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Reviews (3): Last reviewed commit: "Merge branch 'policy_agent_revoke_access..." | Re-trigger Greptile