Skip to content

Commit

Permalink
Do not log error after every mutator exit, it's redundant
Browse files Browse the repository at this point in the history
  • Loading branch information
denik committed Jan 23, 2025
1 parent 720c121 commit 0f46e56
Show file tree
Hide file tree
Showing 18 changed files with 9 additions and 76 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

>>> errcode $CLI bundle validate -o json -t development
11:26:56 ERROR Error: file ./test1.py not found pid=3731 mutator=initialize mutator=seq mutator=TranslatePaths
11:26:56 ERROR Error: file ./test1.py not found pid=3731 mutator=initialize mutator=seq
11:26:56 ERROR Error: file ./test1.py not found pid=3731 mutator=initialize
Error: file ./test1.py not found


Expand Down
6 changes: 0 additions & 6 deletions acceptance/bundle/override/job_tasks/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
}

>>> errcode $CLI bundle validate -o json -t staging
11:26:56 ERROR Error: file ./test1.py not found pid=3757 mutator=initialize mutator=seq mutator=TranslatePaths
11:26:56 ERROR Error: file ./test1.py not found pid=3757 mutator=initialize mutator=seq
11:26:56 ERROR Error: file ./test1.py not found pid=3757 mutator=initialize
Error: file ./test1.py not found


Expand Down Expand Up @@ -67,9 +64,6 @@ Exit code: 1
}

>>> errcode $CLI bundle validate -t staging
11:26:56 ERROR Error: file ./test1.py not found pid=3761 mutator=initialize mutator=seq mutator=TranslatePaths
11:26:56 ERROR Error: file ./test1.py not found pid=3761 mutator=initialize mutator=seq
11:26:56 ERROR Error: file ./test1.py not found pid=3761 mutator=initialize
Error: file ./test1.py not found

Name: override_job_tasks
Expand Down
6 changes: 0 additions & 6 deletions acceptance/bundle/paths/fallback/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
Exit code: 0

>>> $CLI bundle validate -t error
11:26:57 ERROR Error: notebook this value is overridden not found. Local notebook references are expected
to contain one of the following file extensions: [.py, .r, .scala, .sql, .ipynb] pid=3806 mutator=initialize mutator=seq mutator=TranslatePaths
11:26:57 ERROR Error: notebook this value is overridden not found. Local notebook references are expected
to contain one of the following file extensions: [.py, .r, .scala, .sql, .ipynb] pid=3806 mutator=initialize mutator=seq
11:26:57 ERROR Error: notebook this value is overridden not found. Local notebook references are expected
to contain one of the following file extensions: [.py, .r, .scala, .sql, .ipynb] pid=3806 mutator=initialize
Error: notebook this value is overridden not found. Local notebook references are expected
to contain one of the following file extensions: [.py, .r, .scala, .sql, .ipynb]

Expand Down
6 changes: 0 additions & 6 deletions acceptance/bundle/paths/nominal/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
Exit code: 0

>>> $CLI bundle validate -t error
11:26:57 ERROR Error: notebook this value is overridden not found. Local notebook references are expected
to contain one of the following file extensions: [.py, .r, .scala, .sql, .ipynb] pid=3814 mutator=initialize mutator=seq mutator=TranslatePaths
11:26:57 ERROR Error: notebook this value is overridden not found. Local notebook references are expected
to contain one of the following file extensions: [.py, .r, .scala, .sql, .ipynb] pid=3814 mutator=initialize mutator=seq
11:26:57 ERROR Error: notebook this value is overridden not found. Local notebook references are expected
to contain one of the following file extensions: [.py, .r, .scala, .sql, .ipynb] pid=3814 mutator=initialize
Error: notebook this value is overridden not found. Local notebook references are expected
to contain one of the following file extensions: [.py, .r, .scala, .sql, .ipynb]

Expand Down
3 changes: 0 additions & 3 deletions acceptance/bundle/syncroot/dotdot-git/output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
11:26:57 ERROR Error: path "$TMPDIR" is not within repository root "$TMPDIR/myrepo" pid=3887 mutator=validate mutator (read-only)=parallel mutator (read-only)=validate:files_to_sync
11:26:57 ERROR Error: path "$TMPDIR" is not within repository root "$TMPDIR/myrepo" pid=3887 mutator=validate mutator (read-only)=parallel
11:26:57 ERROR Error: path "$TMPDIR" is not within repository root "$TMPDIR/myrepo" pid=3887 mutator=validate
Error: path "$TMPDIR" is not within repository root "$TMPDIR/myrepo"

Name: test-bundle
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/templates/dbt-sql/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Workspace:
Validation OK!

>>> $CLI bundle validate -t prod
11:26:57 WARN target with 'mode: production' should specify an explicit 'targets.prod.git' configuration pid=3865 mutator=initialize mutator=seq mutator=ProcessTargetMode
11:31:28 WARN target with 'mode: production' should specify an explicit 'targets.prod.git' configuration pid=20104 mutator=initialize mutator=seq mutator=ProcessTargetMode
Name: my_dbt_sql
Target: prod
Workspace:
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/templates/default-python/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Workspace:
Validation OK!

>>> $CLI bundle validate -t prod
11:26:57 WARN target with 'mode: production' should specify an explicit 'targets.prod.git' configuration pid=3862 mutator=initialize mutator=seq mutator=ProcessTargetMode
11:31:29 WARN target with 'mode: production' should specify an explicit 'targets.prod.git' configuration pid=20387 mutator=initialize mutator=seq mutator=ProcessTargetMode
Name: my_default_python
Target: prod
Workspace:
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/templates/default-sql/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Workspace:
Validation OK!

>>> $CLI bundle validate -t prod
11:26:57 WARN target with 'mode: production' should specify an explicit 'targets.prod.git' configuration pid=3938 mutator=initialize mutator=seq mutator=ProcessTargetMode
11:31:29 WARN target with 'mode: production' should specify an explicit 'targets.prod.git' configuration pid=20374 mutator=initialize mutator=seq mutator=ProcessTargetMode
Name: my_default_sql
Target: prod
Workspace:
Expand Down
11 changes: 4 additions & 7 deletions acceptance/bundle/undefined_resources/output.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
11:26:57 ERROR Error: pipeline undefined-pipeline is not defined pid=3810 mutator=initialize mutator=seq mutator=validate:AllResourcesHaveValues
11:26:57 ERROR Error: pipeline undefined-pipeline is not defined pid=3810 mutator=initialize mutator=seq
11:26:57 ERROR Error: pipeline undefined-pipeline is not defined pid=3810 mutator=initialize
Error: pipeline undefined-pipeline is not defined
at resources.pipelines.undefined-pipeline
in databricks.yml:14:24

Error: experiment undefined-experiment is not defined
at resources.experiments.undefined-experiment
in databricks.yml:11:26
Expand All @@ -13,6 +6,10 @@ Error: job undefined-job is not defined
at resources.jobs.undefined-job
in databricks.yml:6:19

Error: pipeline undefined-pipeline is not defined
at resources.pipelines.undefined-pipeline
in databricks.yml:14:24

Found 3 errors

Name: undefined-job
Expand Down
1 change: 0 additions & 1 deletion acceptance/bundle/variables/arg-repeat/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Exit code: 0
}

>>> errcode $CLI bundle validate --var a=one --var a=two
11:26:57 ERROR Error: failed to assign two to a: variable has already been assigned value: one pid=3768 mutator=<func>
Error: failed to assign two to a: variable has already been assigned value: one

Name: arg-repeat
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
11:26:57 ERROR Error: expected a map to index "variables.catalog.value.name", found string pid=3864 mutator=initialize mutator=seq mutator=ResolveVariableReferences
11:26:57 ERROR Error: expected a map to index "variables.catalog.value.name", found string pid=3864 mutator=initialize mutator=seq
11:26:57 ERROR Error: expected a map to index "variables.catalog.value.name", found string pid=3864 mutator=initialize
Error: expected a map to index "variables.catalog.value.name", found string

{
Expand Down
3 changes: 0 additions & 3 deletions acceptance/bundle/variables/cycle/output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
11:26:57 ERROR Error: cycle detected in field resolution: variables.a.default -> var.b -> var.a -> var.b pid=3849 mutator=initialize mutator=seq mutator=ResolveVariableReferences
11:26:57 ERROR Error: cycle detected in field resolution: variables.a.default -> var.b -> var.a -> var.b pid=3849 mutator=initialize mutator=seq
11:26:57 ERROR Error: cycle detected in field resolution: variables.a.default -> var.b -> var.a -> var.b pid=3849 mutator=initialize
Error: cycle detected in field resolution: variables.a.default -> var.b -> var.a -> var.b

{
Expand Down
3 changes: 0 additions & 3 deletions acceptance/bundle/variables/empty/output.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
11:26:57 ERROR Error: no value assigned to required variable a. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_a environment variable pid=3821 mutator=initialize mutator=seq mutator=SetVariables
11:26:57 ERROR Error: no value assigned to required variable a. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_a environment variable pid=3821 mutator=initialize mutator=seq
11:26:57 ERROR Error: no value assigned to required variable a. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_a environment variable pid=3821 mutator=initialize
Error: no value assigned to required variable a. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_a environment variable

Name: empty${var.a}
Expand Down
6 changes: 0 additions & 6 deletions acceptance/bundle/variables/env_overrides/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
"prod-a env-var-b"

>>> errcode $CLI bundle validate -t env-missing-a-required-variable-assignment
11:26:57 ERROR Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable pid=4097 mutator=initialize mutator=seq mutator=SetVariables
11:26:57 ERROR Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable pid=4097 mutator=initialize mutator=seq
11:26:57 ERROR Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable pid=4097 mutator=initialize
Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable

Name: test bundle
Expand All @@ -25,9 +22,6 @@ Found 1 error
Exit code: 1

>>> errcode $CLI bundle validate -t env-using-an-undefined-variable
11:26:57 ERROR Error: variable c is not defined but is assigned a value pid=4110 mutator=load mutator=seq mutator=SelectTarget(env-using-an-undefined-variable)
11:26:57 ERROR Error: variable c is not defined but is assigned a value pid=4110 mutator=load mutator=seq
11:26:57 ERROR Error: variable c is not defined but is assigned a value pid=4110 mutator=load
Error: variable c is not defined but is assigned a value

Name: test bundle
Expand Down
6 changes: 0 additions & 6 deletions acceptance/bundle/variables/host/output.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@

>>> errcode $CLI bundle validate -o json
11:26:57 ERROR Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name pid=4050 mutator=initialize mutator=seq mutator=PopulateCurrentUser
11:26:57 ERROR Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name pid=4050 mutator=initialize mutator=seq
11:26:57 ERROR Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name pid=4050 mutator=initialize
Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name

{
Expand All @@ -29,9 +26,6 @@ Error: failed during request visitor: parse "https://${var.host}": invalid chara
Exit code: 1

>>> errcode $CLI bundle validate
11:26:57 ERROR Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name pid=4054 mutator=initialize mutator=seq mutator=PopulateCurrentUser
11:26:57 ERROR Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name pid=4054 mutator=initialize mutator=seq
11:26:57 ERROR Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name pid=4054 mutator=initialize
Error: failed during request visitor: parse "https://${var.host}": invalid character "{" in host name

Name: host
Expand Down
3 changes: 0 additions & 3 deletions acceptance/bundle/variables/vanilla/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"abc def"

>>> errcode $CLI bundle validate
11:26:57 ERROR Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable pid=3780 mutator=initialize mutator=seq mutator=SetVariables
11:26:57 ERROR Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable pid=3780 mutator=initialize mutator=seq
11:26:57 ERROR Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable pid=3780 mutator=initialize
Error: no value assigned to required variable b. Assignment can be done through the "--var" flag or by setting the BUNDLE_VAR_b environment variable

Name: ${var.a} ${var.b}
Expand Down
12 changes: 1 addition & 11 deletions bundle/mutator.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,7 @@ func Apply(ctx context.Context, b *Bundle, m Mutator) diag.Diagnostics {
}
}()

diags := m.Apply(ctx, b)

// Log error in diagnostics if any.
// Note: errors should be logged when constructing them
// such that they are not logged multiple times.
// If this is done, we can omit this block.
if err := diags.Error(); err != nil {
log.Errorf(ctx, "Error: %s", err)
}

return diags
return m.Apply(ctx, b)
}

type funcMutator struct {
Expand Down
7 changes: 1 addition & 6 deletions bundle/mutator_read_only.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,5 @@ func ApplyReadOnly(ctx context.Context, rb ReadOnlyBundle, m ReadOnlyMutator) di
ctx = log.NewContext(ctx, log.GetLogger(ctx).With("mutator (read-only)", m.Name()))

log.Debugf(ctx, "ApplyReadOnly")
diags := m.Apply(ctx, rb)
if err := diags.Error(); err != nil {
log.Errorf(ctx, "Error: %s", err)
}

return diags
return m.Apply(ctx, rb)
}

0 comments on commit 0f46e56

Please sign in to comment.