Skip to content

fix: honor inherited DAG type during validation#1981

Merged
yottahmd merged 4 commits intomainfrom
fix/base-config-type-inheritance-validation
Apr 9, 2026
Merged

fix: honor inherited DAG type during validation#1981
yottahmd merged 4 commits intomainfrom
fix/base-config-type-inheritance-validation

Conversation

@yottahmd
Copy link
Copy Markdown
Collaborator

@yottahmd yottahmd commented Apr 9, 2026

Summary

  • make the file-backed DAG store apply the configured base config when validating and loading DAG specs
  • route API DAG validation and spec-loading paths through the base-config-aware store so inherited type: graph is honored consistently
  • add regression coverage for store loading and API validate/create/get-spec/update flows when the base config provides DAG type

Root cause

Several validation and spec-loading paths bypassed the configured base config and loaded raw DAG YAML directly. DAGs that relied on an inherited base type: graph were therefore validated as the default chain, which rejected explicit depends.

Test plan

  • go test ./internal/persis/filedag -count=1
  • go test ./internal/cmd -run 'TestRebuildDAGFromYAML_ReappliesBaseConfigContent|TestRestoreDAGFromStatus_RestoresRegistryAuthsFromBaseConfig' -count=1
  • go test ./internal/core/spec -run 'TestLoad(_TypeInheritanceFromBaseConfig|YAMLWithOpts_TypeInheritanceInMultiDocumentYAML)' -count=1
  • go test ./internal/service/frontend/api/v1 -count=1

Closes #1979

Summary by CodeRabbit

  • New Features

    • Added support for DAGs to inherit configuration (such as graph type) from a base config file.
  • Refactor

    • Updated DAG specification loading endpoints to use the store abstraction, enabling consistent base config application across validation and retrieval operations.
  • Tests

    • Added tests verifying base config inheritance in DAG specifications and API endpoints.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9e56befd-f49c-4c95-bd7d-87f66e3d6660

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The pull request adds base config path propagation through the DAG store initialization chain. When a base config file is configured, DAG specs loaded through the store now inherit configuration (such as type) from that base config, and conditional logic bypasses file caching and index loading in favor of direct filesystem scanning when a base config path is set.

Changes

Cohort / File(s) Summary
Store Configuration Initialization
internal/cmd/context.go, internal/test/helper.go, internal/test/scheduler.go
Propagate base config path to filedag store via WithBaseConfig() option during initialization in three locations.
Core DAG Store Logic
internal/persis/filedag/store.go
Add BaseConfigPath option and storage field; introduce conditional helpers (hasBaseConfig, defaultLoadOptions, useCachedLoads, useIndexedMetadata); bypass file cache and index loading when base config is set; apply base config option consistently in GetMetadata, GetDetails, LoadSpec, UpdateSpec, List, and Grep.
API Spec Loading
internal/service/frontend/api/v1/dags.go
Switch DAG loading in validation and creation endpoints from spec.LoadYAML() to a.dagStore.LoadSpec(), removing explicit spec.WithoutEval() configuration.
Test Coverage
internal/persis/filedag/store_test.go, internal/service/frontend/api/v1/dags_test.go
Add tests validating that DAG specs inherit type field and dependency resolution from base config files.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API as Frontend API
    participant Store as DAG Store
    participant FS as Filesystem
    participant Spec as Spec Loader

    Client->>API: Create/Validate DAG (steps only)
    API->>Store: LoadSpec(dagYAML)
    activate Store
    Store->>Store: defaultLoadOptions()
    Note over Store: Check if baseConfigPath set
    alt Base Config Path Set
        Store->>FS: Read base config file
        FS-->>Store: Base config content
        Store->>Spec: LoadSpec with WithBaseConfig()
    else No Base Config Path
        Store->>Spec: LoadSpec (standard options)
    end
    deactivate Store
    Spec->>Spec: Merge base config into DAG spec
    Spec-->>Store: Loaded DAG (type inherited)
    Store-->>API: DAG with type: graph
    API-->>Client: Validation succeeds / DAG created
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: honor inherited DAG type during validation' directly reflects the main change: ensuring DAGs inherit type from base config during validation.
Linked Issues check ✅ Passed Changes implement the objective from #1979 by routing validation and spec-loading through base-config-aware store and adding regression tests.
Out of Scope Changes check ✅ Passed All changes directly support base config type inheritance: store adds BaseConfig option, API routes through store, and tests verify the feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/base-config-type-inheritance-validation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

Copy link
Copy Markdown

@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

🧹 Nitpick comments (1)
internal/test/helper.go (1)

246-251: Initialize the base config in the helper before constructing the store.

Production startup creates the default base config in internal/cmd/context.go:392-404, but this helper only forwards cfg.Paths.BaseConfig into filedag.New(...). Mirroring that initialization here would keep helper-backed tests aligned with real server/scheduler startup semantics and avoid depending on an uninitialized base_config path.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/test/helper.go` around lines 246 - 251, Before calling filedag.New
to create dagStore, ensure the default base config is created at
cfg.Paths.BaseConfig exactly as done in production startup; replicate the
initialization logic used in internal/cmd/context.go so cfg.Paths.BaseConfig is
populated (create the default base_config file/directory or invoke the same
helper that writes defaults) and only then call filedag.New(...,
filedag.WithBaseConfig(cfg.Paths.BaseConfig), ...), ensuring dagStore sees an
initialized base_config path.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@internal/persis/filedag/store.go`:
- Around line 135-145: The methods useCachedLoads, useIndexedMetadata and
hasBaseConfig currently disable the fileCache/index whenever baseConfigPath
exists, causing GetMetadata/List/TagList hot paths to re-parse YAML every call;
instead ensure the cache and index remain enabled but are keyed/invalidated by
the base-config file state: record a fingerprint (mtime or checksum) for
baseConfigPath when building the cache/index and compare it in
useCachedLoads/useIndexedMetadata (or subscribe to file changes) so you only
rebuild the cache/index when the base-config file actually changed; update
functions referencing baseConfigPath/fileExists (hasBaseConfig) to check
fingerprint equality and trigger invalidation rather than blanket disabling.

---

Nitpick comments:
In `@internal/test/helper.go`:
- Around line 246-251: Before calling filedag.New to create dagStore, ensure the
default base config is created at cfg.Paths.BaseConfig exactly as done in
production startup; replicate the initialization logic used in
internal/cmd/context.go so cfg.Paths.BaseConfig is populated (create the default
base_config file/directory or invoke the same helper that writes defaults) and
only then call filedag.New(..., filedag.WithBaseConfig(cfg.Paths.BaseConfig),
...), ensuring dagStore sees an initialized base_config path.
🪄 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: Pro

Run ID: 03b7273f-92ed-406d-9b8d-1c7660ecbcd1

📥 Commits

Reviewing files that changed from the base of the PR and between 9d80ee8 and 36370e1.

📒 Files selected for processing (7)
  • internal/cmd/context.go
  • internal/persis/filedag/store.go
  • internal/persis/filedag/store_test.go
  • internal/service/frontend/api/v1/dags.go
  • internal/service/frontend/api/v1/dags_test.go
  • internal/test/helper.go
  • internal/test/scheduler.go

Comment thread internal/persis/filedag/store.go
@yottahmd yottahmd merged commit 493e192 into main Apr 9, 2026
4 checks passed
@yottahmd yottahmd deleted the fix/base-config-type-inheritance-validation branch April 9, 2026 22:54
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.

Type inheritance for base config still fails validation in v2.4.3

1 participant