Skip to content

Merge pipeline-required-tasks from ruleData config#1786

Open
joejstuart wants to merge 5 commits into
conforma:mainfrom
joejstuart:merge-required-tasks
Open

Merge pipeline-required-tasks from ruleData config#1786
joejstuart wants to merge 5 commits into
conforma:mainfrom
joejstuart:merge-required-tasks

Conversation

@joejstuart

@joejstuart joejstuart commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What:

Merge pipeline-required-tasks from the ruleData configuration into the pipeline required tasks used by the tasks policy. This adds a pipeline_required_tasks rule in pipeline.rego that unions data from both data["pipeline-required-tasks"] (data sources) and data["rule_data__configuration__"]["pipeline-required-tasks"] (ruleData), and updates all consumers in pipeline.rego and tasks.rego to use it.

Why:

Previously, pipeline-required-tasks specified in the ruleData field of a policy configuration was silently ignored. The ec CLI places ruleData under data.rule_data__configuration__, but the tasks policy accessed data["pipeline-required-tasks"] directly — bypassing the ruleData namespace entirely. This meant users could not extend pipeline-required-tasks via their policy config and had to provide a separate data source file instead.

Tickets:

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds rule-data overrides for pipeline-required-tasks, uses the merged mapping during Tekton task selection, and validates the merged data during release task checks.

Changes

Pipeline required-task overrides

Layer / File(s) Summary
Merge and resolve required tasks
policy/lib/rule_data/rule_data.rego, policy/lib/tekton/pipeline.rego, policy/lib/tekton/pipeline_test.rego
Adds an object default for rule-data configuration, merges base and configured mappings with override precedence, uses the merged result for selector-specific resolution, and tests merge and conflict behavior.
Validate merged required-task data
policy/release/tasks/tasks.rego, design/rule-data-merge-pattern.md
Validates the merged mapping schema and each entry’s effective_on format, and documents the object-union default and override semantics.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RuleData
  participant TektonPipeline
  participant ReleaseTaskChecks
  RuleData->>TektonPipeline: provide pipeline-required-tasks overrides
  TektonPipeline->>TektonPipeline: merge base and configured mappings
  TektonPipeline->>ReleaseTaskChecks: validate merged required-task data
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: merging pipeline-required-tasks from ruleData config.
Description check ✅ Passed The description covers What and Why well, but the Tickets section is left empty.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@qodo-for-conforma

Copy link
Copy Markdown

PR Summary by Qodo

Merge pipeline-required-tasks from ruleData configuration

🐞 Bug fix ✨ Enhancement 🕐 20-40 Minutes

Grey Divider

AI Description

• Merge pipeline-required-tasks from base data and ruleData policy configuration.
• Route all required-task lookups through a single merged pipeline_required_tasks object.
• Validate schema and timestamps against the merged data to catch config errors early.
Diagram

graph TD
  Base[("Base data\npipe-required") --> Union["Union tasks"] --> Tekton["Tekton lib"] --> Tasks["Tasks policy"]
  Rule[("ruleData config") --> Union
  subgraph Legend
    direction LR
    _db[("Data source")] ~~~ _proc["Merge/compute"] ~~~ _mod["Policy module"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Deep-merge per selector (append arrays)
  • ➕ Allows ruleData to override/extend selectors already defined in base data
  • ➕ Avoids potential key-collision issues when both sources define the same selector
  • ➖ More complex merging logic (need per-key concatenation and de-dup semantics)
  • ➖ Higher risk of subtle behavior changes in required-task resolution
2. Normalize inputs at ingestion (flatten ruleData into base namespace)
  • ➕ Keeps downstream policies unchanged (continue reading data["pipeline-required-tasks"])
  • ➕ Centralizes config-vs-data precedence decisions in one place
  • ➖ Requires changes outside these policies (input shaping/loader behavior)
  • ➖ Harder to reason about provenance of values during debugging

Recommendation: Current approach (introducing tekton.pipeline_required_tasks as the single merged accessor) is a good balance: minimal surface-area change, keeps consumers consistent, and makes validation apply to both sources. If users are expected to override existing selectors (not just add new ones), consider a follow-up to implement a per-selector deep merge instead of object.union to avoid conflicts on overlapping keys.

Files changed (2) +14 / -4

Bug fix (2) +14 / -4
pipeline.regoAdd merged 'pipeline_required_tasks' and use it for lookups +12/-2

Add merged 'pipeline_required_tasks' and use it for lookups

• Introduces defaults and bindings for base ('data["pipeline-required-tasks"]') and ruleData config ('data["rule_data__configuration__"]["pipeline-required-tasks"]'). Exposes 'pipeline_required_tasks' as 'object.union' of both sources and updates required-task selection logic to read from the merged object.

policy/lib/tekton/pipeline.rego

tasks.regoValidate and iterate over merged required-task data +2/-2

Validate and iterate over merged required-task data

• Switches pipeline-required-tasks schema validation to use 'tekton.pipeline_required_tasks' so ruleData-provided entries are validated. Updates the RFC3339 'effective_on' checks to iterate over the merged object rather than only the base data map.

policy/release/tasks/tasks.rego

@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unit-tests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
policy/lib/rule_data/rule_data.rego 100.00% <ø> (ø)
policy/lib/tekton/pipeline.rego 100.00% <100.00%> (ø)
policy/lib/tekton/pipeline_test.rego 100.00% <100.00%> (ø)
policy/release/tasks/tasks.rego 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@qodo-for-conforma

qodo-for-conforma Bot commented Jul 23, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 15 rules

Grey Divider


Action required

1. Union can break validation 🐞 Bug ☼ Reliability
Description
tekton.pipeline_required_tasks is computed via object.union over two unvalidated data values,
and tasks.rego now validates/iterates over this computed value; if either input is a defined
non-object, evaluation may fail before _data_errors can emit the intended structured format error.
This turns a user configuration mistake into a hard policy failure instead of a
tasks.data_provided result with actionable diagnostics.
Code

policy/lib/tekton/pipeline.rego[R11-19]

+default _prt_base := {}
+
+_prt_base := data["pipeline-required-tasks"]
+
+default _prt_config := {}
+
+_prt_config := data["rule_data__configuration__"]["pipeline-required-tasks"]
+
+pipeline_required_tasks := object.union(_prt_base, _prt_config)
Relevance

⭐⭐⭐ High

Repo prefers guarding untrusted data with is_object checks to avoid hard failures and preserve
structured errors.

PR-#1715
PR-#1624
PR-#1740

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The merge is performed unconditionally via object.union over values pulled directly from
data[...], and tasks.rego now depends on that merged value for schema validation and for
iterating entries; if the merge cannot be evaluated, _data_errors cannot produce the intended
"unexpected format" failures.

policy/lib/tekton/pipeline.rego[11-20]
policy/release/tasks/tasks.rego[442-456]
policy/release/tasks/tasks.rego[483-495]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`tekton.pipeline_required_tasks` is built with `object.union(_prt_base, _prt_config)` where both operands come directly from `data[...]`. If either value exists but is not an object, downstream rules (schema validation and `some key, entries in ...` iteration) may error out before producing the intended structured `_data_errors` output.

## Issue Context
This PR changed tasks validation to use `tekton.pipeline_required_tasks`, which requires `tekton.pipeline_required_tasks` to *always* evaluate safely even for malformed user-provided data.

## Fix Focus Areas
- policy/lib/tekton/pipeline.rego[11-19]
- policy/release/tasks/tasks.rego[442-456]
- policy/release/tasks/tasks.rego[483-495]

## Proposed fix
1) In `policy/lib/tekton/pipeline.rego`, split raw vs safe values:
  - Read `_prt_base_raw` and `_prt_config_raw` using `object.get(...)` to avoid unsafe nested indexing.
  - Create `_prt_base_obj` / `_prt_config_obj` that coerce to `{}` unless `is_object(...)`.
  - Compute `pipeline_required_tasks := object.union(_prt_base_obj, _prt_config_obj)`.

2) In `policy/release/tasks/tasks.rego`, preserve actionable errors by validating the *raw* sources too:
  - Run `j.validate_schema` against `_prt_base_raw` and `_prt_config_raw` (or add explicit `not is_object(...)` checks) so non-object inputs generate `tasks.data_provided` messages rather than crashing evaluation.
  - Keep the existing merged validation/iteration against `tekton.pipeline_required_tasks` once the merge is guaranteed safe.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread policy/lib/tekton/pipeline.rego Outdated
Comment on lines +11 to +19
default _prt_base := {}

_prt_base := data["pipeline-required-tasks"]

default _prt_config := {}

_prt_config := data["rule_data__configuration__"]["pipeline-required-tasks"]

pipeline_required_tasks := object.union(_prt_base, _prt_config)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Action required

1. Union can break validation 🐞 Bug ☼ Reliability

tekton.pipeline_required_tasks is computed via object.union over two unvalidated data values,
and tasks.rego now validates/iterates over this computed value; if either input is a defined
non-object, evaluation may fail before _data_errors can emit the intended structured format error.
This turns a user configuration mistake into a hard policy failure instead of a
tasks.data_provided result with actionable diagnostics.
Agent Prompt
## Issue description
`tekton.pipeline_required_tasks` is built with `object.union(_prt_base, _prt_config)` where both operands come directly from `data[...]`. If either value exists but is not an object, downstream rules (schema validation and `some key, entries in ...` iteration) may error out before producing the intended structured `_data_errors` output.

## Issue Context
This PR changed tasks validation to use `tekton.pipeline_required_tasks`, which requires `tekton.pipeline_required_tasks` to *always* evaluate safely even for malformed user-provided data.

## Fix Focus Areas
- policy/lib/tekton/pipeline.rego[11-19]
- policy/release/tasks/tasks.rego[442-456]
- policy/release/tasks/tasks.rego[483-495]

## Proposed fix
1) In `policy/lib/tekton/pipeline.rego`, split raw vs safe values:
   - Read `_prt_base_raw` and `_prt_config_raw` using `object.get(...)` to avoid unsafe nested indexing.
   - Create `_prt_base_obj` / `_prt_config_obj` that coerce to `{}` unless `is_object(...)`.
   - Compute `pipeline_required_tasks := object.union(_prt_base_obj, _prt_config_obj)`.

2) In `policy/release/tasks/tasks.rego`, preserve actionable errors by validating the *raw* sources too:
   - Run `j.validate_schema` against `_prt_base_raw` and `_prt_config_raw` (or add explicit `not is_object(...)` checks) so non-object inputs generate `tasks.data_provided` messages rather than crashing evaluation.
   - Keep the existing merged validation/iteration against `tekton.pipeline_required_tasks` once the merge is guaranteed safe.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@policy/lib/tekton/pipeline.rego`:
- Around line 17-19: Guard the inputs used by pipeline_required_tasks before
calling object.union: validate or default _prt_base and _prt_config so both are
objects, including malformed or missing pipeline-required-tasks values. Preserve
valid configuration merging while allowing tasks.rego to emit its structured
schema error for invalid input instead of failing during policy evaluation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 5287c6ab-e174-40a7-b839-bc39f170f284

📥 Commits

Reviewing files that changed from the base of the PR and between 7211d03 and 04e4673.

📒 Files selected for processing (2)
  • policy/lib/tekton/pipeline.rego
  • policy/release/tasks/tasks.rego

Comment thread policy/lib/tekton/pipeline.rego Outdated
Comment on lines +17 to +19
_prt_config := data["rule_data__configuration__"]["pipeline-required-tasks"]

pipeline_required_tasks := object.union(_prt_base, _prt_config)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

command -v opa >/dev/null || {
  echo "OPA is required"
  exit 1
}

if opa eval --format=pretty 'object.union([], {})' >/dev/null 2>&1; then
  echo "Expected object.union to reject a non-object operand"
  exit 1
fi

echo "object.union rejects non-object operands as expected"

Repository: conforma/policy

Length of output: 169


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== policy/lib/tekton/pipeline.rego ==\n'
wc -l policy/lib/tekton/pipeline.rego
sed -n '1,120p' policy/lib/tekton/pipeline.rego

printf '\n== references to pipeline-required-tasks ==\n'
rg -n 'pipeline-required-tasks|rule_data__configuration__|object.union' policy -S

printf '\n== relevant task validation files ==\n'
fd -a 'tasks.rego|pipeline.rego' policy

Repository: conforma/policy

Length of output: 21153


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== policy/release/tasks/tasks.rego: validation and callers ==\n'
sed -n '430,520p' policy/release/tasks/tasks.rego
printf '\n---\n'
sed -n '1,120p' policy/pipeline/required_tasks/required_tasks.rego

printf '\n== policy/lib/tekton/pipeline_test.rego: coverage around malformed inputs ==\n'
sed -n '1,260p' policy/lib/tekton/pipeline_test.rego

Repository: conforma/policy

Length of output: 14967


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== rule_data configuration access and schema handling ==\n'
sed -n '1,260p' policy/lib/rule_data/rule_data.rego
printf '\n---\n'
rg -n 'rule_data__configuration__|validate_schema|schema' policy/lib/rule_data policy -S

printf '\n== pipeline required task tests for malformed config ==\n'
rg -n 'unexpected format|rule_data__configuration__|pipeline-required-tasks' policy/release/tasks/tasks_test.rego policy/pipeline/required_tasks/required_tasks_test.rego policy/lib/tekton/pipeline_test.rego -S

Repository: conforma/policy

Length of output: 46065


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n== policy/lib/rule_data/rule_data.rego ==\n'
wc -l policy/lib/rule_data/rule_data.rego
sed -n '1,240p' policy/lib/rule_data/rule_data.rego

printf '\n== tests referencing malformed rule_data__configuration__ ==\n'
rg -n 'rule_data__configuration__ as|unexpected format|Data .* unexpected format' policy -S

Repository: conforma/policy

Length of output: 35748


🌐 Web query:

OPA Rego object lookup on non-object type error missing object key semantics

💡 Result:

In OPA Rego, attempting to perform an object lookup (e.g., obj.key or obj[key]) on a value that is not an object, or referencing a non-existent key, typically leads to an "undefined" state rather than a standard runtime exception that crashes the policy [1]. When this occurs in a policy evaluation, the rule or expression containing the lookup evaluates to "undefined," which effectively behaves like a failure in many contexts (e.g., it causes the rule body to not be satisfied) [2][1]. Regarding the specific error messages and semantics: 1. Type Errors: If the OPA type checker can determine that a lookup is being performed on a non-object type (or an invalid key), it may throw a "rego_type_error" at compile time or during analysis, stating that the reference is undefined [3][4]. 2. Undefined vs. False: A common point of confusion is that accessing a key whose value is explicitly false is not the same as accessing a missing key [5][6]. Because Rego uses unification, expressions like obj[key] succeed if the lookup yields a value, including false [6]. However, if you use a pattern that interprets the result as a boolean or participates in a generator (e.g., {k | obj[k]}), a false value may be ignored or cause the expression to fail because the evaluation does not unify to true [5][6]. To check for key existence regardless of the value (even if false), it is idiomatic to use an assignment to a wildcard: _ = obj[key] [7][5][6]. 3. Safe Access: To avoid "undefined" results when a key might be missing, you can use the built-in function object.get(object, key, default) [4][2]. This function allows you to specify a default value if the key does not exist, preventing the entire expression from evaluating to "undefined" [4]. In summary, "non-object type" or "undefined ref" errors usually indicate that your policy is attempting to traverse a path that does not exist in the data provided [4][1]. Using object.get or explicit existence checks via _ = obj[key] is the recommended approach for writing robust policies that handle optional or missing data [2][5].

Citations:


🌐 Web query:

OPA object.union non-object operand type error undefined behavior

💡 Result:

In Open Policy Agent (OPA), the object.union and object.union_n built-in functions are strictly designed to operate on objects [1][2]. Passing non-object types (such as strings, arrays, or numbers) as operands to these functions typically results in a runtime error rather than "undefined behavior" in the sense of uncontrolled memory corruption, though older or specific versions may exhibit unexpected behavior like panics [3]. Key technical points regarding these errors include: 1. Expected Behavior: The object.union function expects both arguments to be objects [1][2]. If a non-object is provided, OPA will generally throw a runtime error because the function cannot perform an asymmetric recursive union on incompatible types. 2. Historical Runtime Panics: In some versions of OPA, passing an array containing non-object elements to object.union_n could trigger a runtime panic (specifically a nil pointer dereference) [3]. This is a bug related to unchecked error handling within the function's internal implementation [3]. 3. Type Checking: While many OPA built-in functions have historically been documented with an any return type, they strictly expect object inputs [4]. Efforts have been made to improve OPA's type checker to catch these mismatches at compile time rather than relying on runtime failures [4]. 4. Distinction from Merge Conflicts: Developers occasionally encounter "object merge conflict" errors. This is distinct from a type error; it occurs during recursive merging when the function encounters incompatible structures that cannot be unified (e.g., trying to merge a primitive value into an existing object key) [5]. If you are encountering unexpected behavior, it is recommended to ensure that all data passed to object.union or object.union_n is validated as an object using internal checks or by ensuring your input data structures conform to the expected schema before the built-in is called.

Citations:


Guard the rule-data merge in policy/lib/tekton/pipeline.rego:17-19. object.union only accepts objects, so a malformed data["pipeline-required-tasks"] or data["rule_data__configuration__"]["pipeline-required-tasks"] value can fail policy evaluation before tasks.rego emits the structured schema error. Validate or default both inputs before merging.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@policy/lib/tekton/pipeline.rego` around lines 17 - 19, Guard the inputs used
by pipeline_required_tasks before calling object.union: validate or default
_prt_base and _prt_config so both are objects, including malformed or missing
pipeline-required-tasks values. Preserve valid configuration merging while
allowing tasks.rego to emit its structured schema error for invalid input
instead of failing during policy evaluation.

@joejstuart
joejstuart force-pushed the merge-required-tasks branch from 04e4673 to d704179 Compare July 23, 2026 17:03
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Finished Review · ✅ Success · Started 5:06 PM UTC · Completed 5:21 PM UTC
Commit: 87c4a29 · View workflow run →

@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

Review

Findings

High

  • [protected-path] AGENTS.md — This file is under a protected path that requires human approval for changes. The PR has no linked issue (the "Tickets:" section is empty), so there is no external authorization for modifying governance files. The change itself is minor (4 lines adding a note about the design/ directory), but protected-path changes require explicit justification via a linked issue regardless of size.
    Remediation: Create an issue describing the rationale for the design/ directory convention and link it to this PR, or split the AGENTS.md change into a separate PR with its own authorization.

Medium

  • [stale-description] policy/release/tasks/tasks.rego:10 — The METADATA description for the tasks package states that pipeline-required-tasks is "specified in a data source provided at runtime," but this PR changes the behavior so that pipeline-required-tasks is now a merge of data sources AND ruleData configuration via object.union. This description feeds the auto-generated documentation in antora/docs/modules/ROOT/pages/packages/release_tasks.adoc.
    Remediation: Update the METADATA description block (lines 4–22) in policy/release/tasks/tasks.rego to mention that pipeline-required-tasks values are merged from both data sources and ruleData configuration, with ruleData taking precedence on key conflicts. Then run make generate-docs to regenerate the antora docs.

Low

  • [data-validation-gap] policy/release/tasks/tasks.rego:442 — The _data_errors schema-validation rule now validates the merged tekton.pipeline_required_tasks (union of data-source and ruleData). No test validates that malformed ruleData configuration entries are caught through this merged validation path. The schema validation logic is unchanged (only its input broadened), so the risk is low.

  • [edge-case] policy/lib/tekton/pipeline.rego:12pipeline_required_tasks := object.union(data["pipeline-required-tasks"], rule_data.get("pipeline-required-tasks")) produces undefined if data["pipeline-required-tasks"] is itself undefined (no data source provides it), because object.union requires both arguments to be objects. This matches the pre-PR behavior (no regression), but worth noting.

  • [privilege-escalation] policy/lib/tekton/pipeline.rego:13object.union gives precedence to the ruleData value (second argument) when both sources define entries for the same pipeline selector key. A ruleData configuration could replace data-source requirements for a pipeline type. This mirrors the existing trusted_tasks pattern in trusted.rego and appears intentional.

  • [missing-authorization] — The PR has no linked issue. The "Tickets:" section in the PR body is empty. While the PR body clearly describes the bug and approach, a linked issue would establish explicit scope authorization and provide a decision trail.

  • [visibility-convention] policy/lib/tekton/pipeline.rego:12 — The analogous merged-data rule in trusted.rego uses a private name (_trusted_tasks_data) consumed within the same package. The new pipeline_required_tasks is public because tasks.rego references it for data validation. This is a necessary divergence but breaks pattern symmetry with the trusted_tasks merge site.

Previous run

Review

Findings

Medium

  • [test adequacy] policy/lib/tekton/pipeline.rego:11 — The new pipeline_required_tasks rule merges data from two sources via object.union(data["pipeline-required-tasks"], lib_rule_data("pipeline-required-tasks")), but no test verifies this merge behavior. All existing tests set only data["pipeline-required-tasks"] via with clauses and never provide data through the ruleData configuration path (data.rule_data__configuration__["pipeline-required-tasks"]). Without a test that supplies data from both sources, there is no coverage for: (1) confirming the union produces the expected merged result, (2) verifying that ruleData values take precedence over data-source values when keys conflict, or (3) ensuring the merged result flows correctly through required_task_list, _merged_required_task_list, and the _data_errors validation in tasks.rego.
    Remediation: Add at least one test that provides pipeline-required-tasks via both data["pipeline-required-tasks"] and data.rule_data__configuration__["pipeline-required-tasks"] with overlapping and non-overlapping keys, and asserts the merged output matches expectations.

Low

  • [import-directive consistency] policy/lib/tekton/pipeline.rego:5 — In trusted.rego, the identical import data.lib.rule_data.get as lib_rule_data is preceded by # regal ignore:prefer-package-imports to suppress the regal linter warning. The new import in pipeline.rego omits this directive, which will likely trigger a linter warning in CI.
    Remediation: Add # regal ignore:prefer-package-imports on the line immediately above the new import, matching the pattern in trusted.rego.

  • [override semantics] policy/lib/tekton/pipeline.rego:11object.union(A, B) gives ruleData config (B) full override precedence over data sources (A) for matching selector keys. This is consistent with the existing trusted_tasks pattern in trusted.rego and is by design, but worth documenting since a ruleData entry for a selector key replaces the data-source value entirely rather than merging arrays.
    Remediation: Consider documenting that ruleData configuration intentionally overrides data-source required tasks per selector key, matching the trusted_tasks precedent.

  • [stale-documentation] antora/docs/modules/ROOT/pages/packages/release_tasks.adoc:3 — The introductory paragraph states that pipeline-required-tasks are specified via "a data source provided at runtime." After this PR, they can also come from ruleData configuration. This file is auto-generated from METADATA annotations in tasks.rego.
    Remediation: Update the METADATA description block at the top of tasks.rego to mention both data sources and ruleData configuration, then regenerate docs with make generate-docs.


Labels: PR fixes a bug where ruleData pipeline-required-tasks was silently ignored

fullsend-ai-review[bot]

This comment was marked as outdated.

@fullsend-ai-review fullsend-ai-review Bot added requires-manual-review Review requires human judgment bug Something isn't working labels Jul 23, 2026
The policy now merges pipeline-required-tasks from both data sources
and the ruleData configuration (rule_data__configuration__). This
allows users to extend pipeline-required-tasks via the ruleData field
in their policy config without needing a separate data source file.

Uses the same lib_rule_data pattern as trusted_tasks merging.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@joejstuart
joejstuart force-pushed the merge-required-tasks branch from d704179 to 9b01177 Compare July 23, 2026 19:14
@github-actions github-actions Bot added size: M and removed size: XS labels Jul 23, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 7:15 PM UTC · Ended 7:21 PM UTC
Commit: 87c4a29 · View workflow run →

Document the non-obvious interaction between rule_data.get() defaults,
object.union safety, and override precedence — knowledge needed by anyone
adding a new data-source/ruleData merge.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added size: L and removed size: M labels Jul 23, 2026
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 7:22 PM UTC · Ended 7:38 PM UTC
Commit: 87c4a29 · View workflow run →

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@design/rule-data-merge-pattern.md`:
- Around line 36-38: Clarify in the rule_data merge documentation that the
defaults map, including the {} default in rule_data.rego, applies only when the
key is absent and does not protect against explicitly supplied arrays or other
invalid types. Require validating present values or applying a safe object
fallback before object.union, preventing invalid data from silently producing
zero violations and errors.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: ba1678e9-e875-4bc9-8bcc-2de34e6a1e24

📥 Commits

Reviewing files that changed from the base of the PR and between 9b01177 and ed762e5.

📒 Files selected for processing (1)
  • design/rule-data-merge-pattern.md

Comment on lines +36 to +38
This means a misconfigured data source that provides an array instead of an object will
cause policy rules to silently stop evaluating, producing zero violations and zero errors.
The `{}` default in rule_data.rego is the primary defense against this.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Clarify that {} does not protect against wrong-typed values.

The defaults map is consulted only when the key is absent. If a data source explicitly supplies an array, rule_data.get(...) still returns that array and object.union remains undefined. Document this limitation and require type validation or a safe fallback for present, invalid values; otherwise this can still fail open with zero policy violations.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@design/rule-data-merge-pattern.md` around lines 36 - 38, Clarify in the
rule_data merge documentation that the defaults map, including the {} default in
rule_data.rego, applies only when the key is absent and does not protect against
explicitly supplied arrays or other invalid types. Require validating present
values or applying a safe object fallback before object.union, preventing
invalid data from silently producing zero violations and errors.

Fixes opa-check strict mode: assigned var attestation unused.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 7:38 PM UTC · Ended 7:49 PM UTC
Commit: 87c4a29 · View workflow run →

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Review · ⚠️ Cancelled · Started 7:50 PM UTC · Ended 7:52 PM UTC
Commit: 87c4a29 · View workflow run →

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fullsend-ai-review

fullsend-ai-review Bot commented Jul 23, 2026

Copy link
Copy Markdown

🤖 Finished Review · ❌ Failure · Started 7:53 PM UTC · Completed 8:10 PM UTC
Commit: 87c4a29 · View workflow run →

@joejstuart

Copy link
Copy Markdown
Contributor Author

This was created from a slack conversation, so I still need to create a story.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working requires-manual-review Review requires human judgment size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant