Skip to content

[ON HOLD] feat(cli): enable lineage emission by default (opt out with --no-emit-lineage) - #2367

Open
rafal-hawrylak wants to merge 5 commits into
mainfrom
feat-cli-lineage-default-on
Open

rafal-hawrylak wants to merge 5 commits into
mainfrom
feat-cli-lineage-default-on

Conversation

@rafal-hawrylak

@rafal-hawrylak rafal-hawrylak commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

dataform run now emits OpenLineage events to Knowledge Catalog Lineage by default. Previously lineage was opt-in (--emit-lineage or lineage.enabled: true in workflow_settings.yaml).

Precedence is unchanged:

  1. --emit-lineage / --no-emit-lineage (per invocation)
  2. workflow_settings.yaml → lineage.enabled (per project)
  3. Default: enabled (new)

Changes

  • cli/api/lineage/enablement.ts (new): resolveLineageEnablement() returns the effective setting and which surface decided it (cli_flag / workflow_settings / default). LINEAGE_ENABLED_BY_DEFAULT = true.
  • cli/api/lineage/emitter_factory.ts: uses the resolver instead of ?? false and passes the source to the emitter. Explicit opt-outs still print skip_reason=invocation_override / skip_reason=workflow_opt_out.
  • cli/api/lineage/emitter.ts: when lineage is on only by default, expected one-time notices (api_disabled, unauthenticated, endpoint_region_mismatch, dry_run, REP→global fallback) are printed only with DATAFORM_LINEAGE_DEBUG=1, so output is unchanged for users who never configured lineage. Unexpected Failed to emit errors are still surfaced: the first one in a run is printed (with a hint to set DATAFORM_LINEAGE_DEBUG=1), later ones only in debug mode. With an explicit opt-in (flag or yaml), all notices and failures are printed as before. Emission stays fail-open.
  • cli/commands/run_options.ts, cli/README.md, protos/configs.proto: document the new default and --no-emit-lineage.

Testing

  • New enablement_test.ts (all 9 flag × yaml combinations); new/updated cases in emitter_test.ts, emitter_factory_test.ts, lineage_integration_test.ts (default-on emits; default-on skip is silent and fail-open; only the first default-mode emit failure per run is printed).
  • ./scripts/run_tests: 65/65 pass. ./scripts/run_integration_tests: 19/19 pass (incl. index_run_e2e_test and JiT e2e suites). ./scripts/lint clean.
  • Live test with the built CLI on 14 scenarios, all exit 0:
Scenario Lineage output Emitted
No lineage: block, no flag (Lineage API on, permitted) none ✅ verified via Lineage API
--no-emit-lineage skip_reason=invocation_override ❌
lineage.enabled: false skip_reason=workflow_opt_out ❌
lineage.enabled: false + --emit-lineage none ✅
Default, Lineage API not enabled none (debug: skip_reason=api_disabled) ❌
--emit-lineage, Lineage API not enabled skip_reason=api_disabled ❌
Default, no Lineage permission on target project none (debug: skip_reason=api_disabled) ❌
--dry-run (default / --emit-lineage) none / skip_reason=dry_run —

…-lineage)

`dataform run` now emits OpenLineage events to Knowledge Catalog Lineage by
default. Precedence is unchanged: --emit-lineage / --no-emit-lineage overrides
workflow_settings.yaml `lineage.enabled`, which overrides the default.

When lineage is on only because of the default, expected one-time skip notices
(API not enabled, missing permission, dry-run, REP fallback) are printed only
with DATAFORM_LINEAGE_DEBUG=1, so output is unchanged for users who never
configured lineage. Unexpected emit failures are still reported. Emission
stays fail-open and never changes the run result.
@rafal-hawrylak
rafal-hawrylak requested a review from a team as a code owner October 12, 2026 13:49
@rafal-hawrylak
rafal-hawrylak requested review from kolina and removed request for a team October 12, 2026 13:49
Comment thread cli/api/lineage/enablement.ts Resolved
Comment thread protos/configs.proto Resolved
Comment thread cli/api/lineage/emitter.ts Resolved
Comment thread cli/api/lineage/emitter_factory.ts Resolved
Comment thread cli/api/lineage/emitter_factory.ts Resolved
Comment thread cli/commands/run_options.ts Resolved
Comment thread cli/api/lineage/emitter_test.ts Resolved
@rafal-hawrylak rafal-hawrylak changed the title feat(cli): enable lineage emission by default (opt out with --no-emit-lineage) [ON HOLD] feat(cli): enable lineage emission by default (opt out with --no-emit-lineage) Oct 15, 2026
@rafal-hawrylak

Copy link
Copy Markdown
Collaborator Author

We're going to have it OFF by default for a while still and get back to it in a month or two.

- Print `Failed to emit` lines only with DATAFORM_LINEAGE_DEBUG=1 when lineage
  is on only by default, like the skip notices.
- Mention `--no-emit-lineage` in the invocation_override skip message.
- Explain why `--emit-lineage` has no yargs default.
- Move `withDebugEnv` into `cli/api/lineage/testing/debug_env.ts` and use it in
  the emitter and integration tests.
- Order integration Case 7 after Case 6.
@apilaskowski

Copy link
Copy Markdown
Collaborator

Should I review, even if this is ON HOLD? Let me know :)

@rafal-hawrylak

Copy link
Copy Markdown
Collaborator Author

Should I review, even if this is ON HOLD? Let me know :)

This is going to be merged in this shape anyway. So this is matter of "when" not "if" here.

const location = (e as any).lineageLocation || "unknown";
this.stderr.write(
this.writeNotice(
`[lineage] Failed to emit lineage for action ${action.target.schema}.${action.target.name}: ` +

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The PR description says "Unexpected Failed to emit errors are still printed", but this line now goes through writeNotice(), so it is hidden when enablementSource === "default" (and the hides the Failed to emit line for unexpected errors test locks that in). Which is intended? I'd lean toward keeping this one on this.stderr.write — genuinely unexpected errors (e.g. INVALID_ARGUMENT from a payload bug) would otherwise go unnoticed for the majority of users who just rely on the default. Either way, please align the description/README with the behavior.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Compromise: first failure per run printed, rest debug-only.

Comment thread protos/configs.proto
// Catalog for actions executed from this project.
// Catalog for actions executed from this project. When the `lineage` block
// is not set, runners emit lineage by default.
bool enabled = 1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

enabled is a proto3 scalar without presence, and core/workflow_settings.ts copies it whenever the lineage block exists (if (workflowSettings.lineage) projectConfig.lineageEnabled = workflowSettings.lineage.enabled;). With default-on, an empty lineage: {} block (or one that later only sets other sub-fields) now resolves to enabled=false and silently opts the project out with skip_reason=workflow_opt_out. Could we make this optional bool enabled = 1; and only propagate it when explicitly set? A test for the empty-block case would be good too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Checked: {} compiles to unset

* line is shown only with DATAFORM_LINEAGE_DEBUG=1 to keep their output
* unchanged (for example in air-gapped CI or behind a proxy).
*/
private writeNotice(msg: string): void {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: this.debugEnabled is captured in the constructor, which is why withDebugEnv needs the "create the emitter inside fn" caveat. Fine as is, just noting it's easy to trip over — maybe mention it on the field too.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -8,6 +9,12 @@ import { dataform } from "df/protos/ts";

export interface IEmitterOptions {
lineageEnabled?: boolean;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: lineageEnabled is now always true whenever an emitter is constructed, so it's redundant next to enablementSource. Consider deprecating/removing it to avoid confusion.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Marked deprecated - removal in follow-up

Comment thread cli/api/lineage/enablement_test.ts Outdated

suite("resolveLineageEnablement", () => {
test("lineage is enabled by default", () => {
expect(LINEAGE_ENABLED_BY_DEFAULT).to.equal(true);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: this test just restates the constant; the table cases below (cli=undefined yaml=undefined → enabled=true) already pin the default behavior. Could be dropped.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Removed

Comment thread cli/README.md Outdated
| `--job-prefix` | string | — | Adds an additional prefix to BigQuery job IDs, in the form `dataform-${jobPrefix}-`. |
| `--job-labels` | string | — | Comma-separated `key=value` labels to attach to BigQuery jobs, e.g. `'key1=val1,key2=val2'`. |
| `--emit-lineage` | boolean | — | Emits OpenLineage `RunEvent`s to Knowledge Catalog Lineage for each executed action. Overrides the `lineage.enabled` setting in `workflow_settings.yaml` when specified. |
| `--emit-lineage` | boolean | `true` | Emits OpenLineage `RunEvent`s to Knowledge Catalog Lineage for each executed action. Enabled by default; pass `--no-emit-lineage` (or set `lineage.enabled: false` in `workflow_settings.yaml`) to disable. Overrides the `lineage.enabled` setting in `workflow_settings.yaml` when specified. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: the Default column says true, but the yargs option intentionally has no default (see comment in run_options.ts) so that workflow_settings.yaml can apply. Maybe "unset (lineage on by default)" to avoid implying the flag overrides the YAML when omitted.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done


suite("--emit-lineage integration", { parallel: true }, () => {
test("Case 1 — CLI flag alone enables emission (2*N recorder calls, pairing invariant)", async () => {
test("CLI flag alone enables emission (2*N recorder calls, pairing invariant)", async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: dropping the "Case N —" prefixes is unrelated cleanup — fine, but could live in a separate commit to keep this diff focused.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done after your earlier suggestion

…eage

- When lineage is on only by default, print the first unexpected
  `Failed to emit` line of a run (with a DATAFORM_LINEAGE_DEBUG hint) instead
  of hiding all of them; later failures still need DATAFORM_LINEAGE_DEBUG=1.
- Note on `debugEnabled` that DATAFORM_LINEAGE_DEBUG is read in the
  constructor.
- Deprecate the unused `IEmitterOptions.lineageEnabled`.
- Drop the enablement test that only restated the constant.
- README: the `--emit-lineage` default is "unset (lineage on by default)".
…ult-on

# Conflicts:
#	cli/api/lineage/emitter.ts
#	cli/api/lineage/lineage_integration_test.ts

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants