Skip to content

Conversation

@yottahmd
Copy link
Collaborator

@yottahmd yottahmd commented Dec 6, 2025

Summary by CodeRabbit

  • New Features

    • continueOn now accepts a shorthand string ("skipped" or "failed") or a detailed object, with support for exitCode and output as single values or arrays and a markSuccess flag.
  • Bug Fixes

    • Stronger, field-specific validation and clearer error messages for continueOn inputs, including case-insensitive string parsing.
  • Tests

    • Added coverage for shorthand strings, object forms, arrays, and invalid continueOn values.
  • Documentation

    • Schema updated to document the string-or-object union and expanded field options.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 6, 2025

Walkthrough

ContinueOn now accepts either a shorthand string ("skipped" or "failed") or a detailed object; step definition ContinueOn was relaxed to any; parsing/validation moved into a type switch with per-field checks; schema and error messages were updated and tests expanded.

Changes

Cohort / File(s) Summary
ContinueOn Parsing Logic
internal/core/spec/builder.go
Added type-switch parsing for continueOn supporting string shorthand and object/map forms; implemented per-field validation and parsing for failure, skipped, markSuccess, exitCode, and output; introduced field-specific error reporting and ErrContinueOnMustBeStringOrMap/ErrContinueOnInvalidStringValue.
Type Definition Updates
internal/core/spec/definition.go
Changed stepDef.ContinueOn from *continueOnDef to any and removed the dedicated continueOnDef struct.
Error Handling
internal/core/spec/errors.go
Normalized error message field names (lowercase), adjusted exitCode/output messages, and added ErrContinueOnMustBeStringOrMap, ErrContinueOnInvalidStringValue, and ErrContinueOnFieldMustBeBool.
Test Coverage
internal/core/spec/builder_test.go
Added tests for string shorthand ("skipped"/"failed", case-insensitive), invalid string values, object-form parsing including exitCode (int/array) and markSuccess, and type/field validation error cases.
Schema Definition
schemas/dag.schema.json
Replaced flat continueOn schema with a union allowing either a shorthand string ("skipped" or "failed") or a detailed object containing failure, skipped, exitCode, output, and markSuccess (with expanded types for exitCode/output).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Review internal/core/spec/builder.go for exhaustive type-switch coverage, nil-handling, and exact error messages.
  • Verify internal/core/spec/definition.go change doesn't break marshaling/unmarshaling elsewhere.
  • Confirm schemas/dag.schema.json correctly expresses the string-or-object union and aligns with parsing logic.
  • Check new tests in internal/core/spec/builder_test.go for completeness and any brittle assertions.

Poem

🐰 I hopped through YAML, two paths to see,

"skipped" or "failed" — or a map that's free.
Ears on a type switch, errors trimmed neat,
Exit codes and outputs now parse so sweet,
A rabbit applauds this tidy parsing treat!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(spec): add continue-on shorthand' directly and accurately describes the main change in the pull request—adding string shorthand parsing (e.g., 'skipped', 'failed') as an alternative to object form for the continueOn field.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch continue-on-shorthand

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec1c9f5 and c4c8cf7.

📒 Files selected for processing (3)
  • internal/core/spec/builder.go (1 hunks)
  • internal/core/spec/builder_test.go (1 hunks)
  • internal/core/spec/errors.go (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • internal/core/spec/builder_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • internal/core/spec/errors.go
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Backend entrypoint in cmd/ orchestrates the scheduler and CLI; runtime, persistence, and service layers sit under internal/* (for example internal/runtime, internal/persistence)
Keep Go files gofmt/goimports clean; use tabs, PascalCase for exported symbols (SchedulerClient), lowerCamelCase for locals, and Err... names for package-level errors
Repository linting relies on golangci-lint; prefer idiomatic Go patterns, minimal global state, and structured logging helpers in internal/common

Files:

  • internal/core/spec/builder.go
🧬 Code graph analysis (1)
internal/core/spec/builder.go (2)
internal/core/step.go (1)
  • ContinueOn (226-232)
internal/core/spec/errors.go (5)
  • ErrContinueOnInvalidStringValue (19-19)
  • ErrContinueOnFieldMustBeBool (20-20)
  • ErrContinueOnExitCodeMustBeIntOrArray (16-16)
  • ErrContinueOnOutputMustBeStringOrArray (17-17)
  • ErrContinueOnMustBeStringOrMap (18-18)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test on ubuntu-latest
🔇 Additional comments (1)
internal/core/spec/builder.go (1)

1308-1358: LGTM! Validation is now consistent across all continueOn fields.

The dual-form implementation correctly handles:

  • String shorthand ("skipped" or "failed") with case-insensitive matching
  • Object form with per-field type validation

The previous concern about bool fields being silently ignored has been addressed. Lines 1323-1341 now return ErrContinueOnFieldMustBeBool for non-bool values, making the validation consistent with exitCode and output field handling.


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

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
schemas/dag.schema.json (1)

656-716: continueOn union matches runtime, but schema is stricter on string casing

The oneOf union and nested exitCode/output shapes line up with the new builder behavior, but the enum branch only allows lowercase "skipped"/"failed" while buildContinueOn accepts case‑insensitive values (e.g. "SKIPPED" is tested). If case‑insensitive input is intended, consider either:

  • Expanding the enum (or using a pattern) to reflect that, or
  • Tightening the builder to require the canonical lowercase values.

This avoids schema vs runtime discrepancies for validators.

internal/core/spec/builder_test.go (1)

1281-1353: Solid coverage for new continueOn forms

These tests nicely exercise the shorthand string values (including case‑insensitive handling), invalid strings, and the object form with exitCode and markSuccess, and they fit well into the existing subtest structure. If you want to tighten coverage further, you could add cases for:

  • exitCode as a single string (e.g. "1") and mixed invalid types, and
  • output as both string and array.

Not strictly necessary for this change set.

internal/core/spec/builder.go (1)

1308-1346: Add TrimSpace to continueOn string parsing and consider map[any]any handling for YAML robustness

The buildContinueOn implementation is correct; two small improvements align it with patterns used elsewhere in the builder:

  1. Normalize whitespace in shorthand strings

Throughout builder.go, string values are normalized with strings.TrimSpace() before processing (e.g., Group, Description, Type, Queue, Name, ID, Script, etc.). The shorthand continueOn parser should do the same so that " skipped " or "failed " work as expected:

	case string:
		// Shorthand syntax: "skipped" or "failed"
-		switch strings.ToLower(v) {
+		switch strings.ToLower(strings.TrimSpace(v)) {
		case "skipped":
			step.ContinueOn.Skipped = true
		case "failed":
			step.ContinueOn.Failure = true
  1. Handle map[any]any for YAML robustness

The buildRegistryAuths function handles both map[string]any and map[any]any to accommodate YAML's type preservation. Although gopkg.in/yaml.v3 defaults to map[string]interface{} for string-keyed mappings, edge cases and version variations can produce map[any]any. Adding a fallback case here (converting keys to strings before processing) would make continueOn more defensive and consistent with other handlers in the builder.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07929d9 and 0a12abf.

📒 Files selected for processing (5)
  • internal/core/spec/builder.go (1 hunks)
  • internal/core/spec/builder_test.go (1 hunks)
  • internal/core/spec/definition.go (1 hunks)
  • internal/core/spec/errors.go (1 hunks)
  • schemas/dag.schema.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Backend entrypoint in cmd/ orchestrates the scheduler and CLI; runtime, persistence, and service layers sit under internal/* (for example internal/runtime, internal/persistence)
Keep Go files gofmt/goimports clean; use tabs, PascalCase for exported symbols (SchedulerClient), lowerCamelCase for locals, and Err... names for package-level errors
Repository linting relies on golangci-lint; prefer idiomatic Go patterns, minimal global state, and structured logging helpers in internal/common

Files:

  • internal/core/spec/builder_test.go
  • internal/core/spec/errors.go
  • internal/core/spec/builder.go
  • internal/core/spec/definition.go
**/*_test.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*_test.go: Co-locate Go tests as *_test.go; favour table-driven cases and cover failure paths
Use stretchr/testify/require and shared fixtures from internal/test instead of duplicating mocks

Files:

  • internal/core/spec/builder_test.go
🧠 Learnings (1)
📚 Learning: 2025-12-04T10:34:17.051Z
Learnt from: CR
Repo: dagu-org/dagu PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-12-04T10:34:17.051Z
Learning: Applies to **/*_test.go : Co-locate Go tests as `*_test.go`; favour table-driven cases and cover failure paths

Applied to files:

  • internal/core/spec/builder_test.go
🧬 Code graph analysis (3)
internal/core/spec/builder_test.go (2)
internal/core/spec/loader.go (1)
  • LoadYAML (150-163)
internal/core/step.go (1)
  • ContinueOn (226-232)
internal/core/spec/builder.go (2)
internal/core/step.go (1)
  • ContinueOn (226-232)
internal/core/spec/errors.go (4)
  • ErrContinueOnInvalidStringValue (19-19)
  • ErrContinueOnExitCodeMustBeIntOrArray (16-16)
  • ErrContinueOnOutputMustBeStringOrArray (17-17)
  • ErrContinueOnMustBeStringOrMap (18-18)
internal/core/spec/definition.go (1)
internal/core/step.go (1)
  • ContinueOn (226-232)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test on ubuntu-latest
🔇 Additional comments (2)
internal/core/spec/definition.go (1)

135-136: ContinueOn field typing and docs align with new shorthand/object support

Using any here and documenting the string vs object forms matches the updated builder logic and JSON schema; no issues from this change alone.

internal/core/spec/errors.go (1)

16-19: continueOn error constants and messages look consistent

The updated messages and the two new error vars cleanly cover invalid string values and non-string/non-object types for continueOn, and match how buildContinueOn reports validation errors.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a12abf and ec1c9f5.

📒 Files selected for processing (1)
  • internal/core/spec/builder.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Backend entrypoint in cmd/ orchestrates the scheduler and CLI; runtime, persistence, and service layers sit under internal/* (for example internal/runtime, internal/persistence)
Keep Go files gofmt/goimports clean; use tabs, PascalCase for exported symbols (SchedulerClient), lowerCamelCase for locals, and Err... names for package-level errors
Repository linting relies on golangci-lint; prefer idiomatic Go patterns, minimal global state, and structured logging helpers in internal/common

Files:

  • internal/core/spec/builder.go
🧬 Code graph analysis (1)
internal/core/spec/builder.go (2)
internal/core/step.go (1)
  • ContinueOn (226-232)
internal/core/spec/errors.go (4)
  • ErrContinueOnInvalidStringValue (19-19)
  • ErrContinueOnExitCodeMustBeIntOrArray (16-16)
  • ErrContinueOnOutputMustBeStringOrArray (17-17)
  • ErrContinueOnMustBeStringOrMap (18-18)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Test on ubuntu-latest

@yottahmd yottahmd merged commit 722028d into main Dec 6, 2025
5 checks passed
@yottahmd yottahmd deleted the continue-on-shorthand branch December 6, 2025 19:30
@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

❌ Patch coverage is 82.85714% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 59.93%. Comparing base (07929d9) to head (c4c8cf7).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
internal/core/spec/builder.go 82.85% 4 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1454      +/-   ##
==========================================
+ Coverage   59.86%   59.93%   +0.06%     
==========================================
  Files         188      188              
  Lines       21167    21191      +24     
==========================================
+ Hits        12671    12700      +29     
+ Misses       7180     7175       -5     
  Partials     1316     1316              
Files with missing lines Coverage Δ
internal/core/spec/builder.go 68.88% <82.85%> (+1.12%) ⬆️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 07929d9...c4c8cf7. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

1 participant