Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR extends the enqueue DAG run endpoint to accept either an inline YAML specification or a filename reference pointing to an existing YAML file. The request body is modified with a new optional filename field and a oneOf constraint, while backend logic handles reading and validating YAML files from disk when a filename is provided. Changes
Sequence Diagram(s)sequenceDiagram
actor Client
participant Handler as API Handler
participant FileSystem as File System
participant Config as Base Config
participant DAGLoader as DAG Loader
Client->>Handler: POST /dags/{fileName}/enqueue<br/>(with Filename)
Handler->>Handler: Validate: not both spec & filename
Handler->>Config: Read base config
Config-->>Handler: Config data
Handler->>Handler: Resolve ALT_DAGS_DIR from env
Handler->>FileSystem: Read YAML file<br/>(check .yaml/.yml extension)
FileSystem-->>Handler: File content (≤1 MiB)
Handler->>DAGLoader: Load DAG from file content
DAGLoader-->>Handler: DAG object
Handler-->>Client: 200 OK (DAG run enqueued)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
internal/service/frontend/api/v2/dagruns.go (1)
261-265:⚠️ Potential issue | 🟡 MinorAudit metadata should reflect filename-based enqueue.
inlineis alwaystrue, even when a filename is used, which makes audit logs inaccurate.🧾 Suggested audit flag fix
- detailsMap := map[string]any{ - "dag_name": dag.Name, - "dag_run_id": dagRunId, - "inline": true, - } + inline := request.Body.Spec != nil + detailsMap := map[string]any{ + "dag_name": dag.Name, + "dag_run_id": dagRunId, + "inline": inline, + } + if request.Body.Filename != nil { + detailsMap["filename"] = *request.Body.Filename + }
🤖 Fix all issues with AI agents
In `@internal/service/frontend/api/v2/dagruns.go`:
- Around line 161-166: Update the user-facing error message so it references the
actual API field name `filename` instead of “url”: change the Error returned in
the branch that checks request.Body.Spec and request.Body.Filename (the
conditional using request.Body.Spec == nil && request.Body.Filename == nil ||
request.Body.Spec != nil && request.Body.Filename != nil) to set Message to
something like "either give spec or filename; don't give both" so clients see
the correct field name.
- Around line 193-212: The current code unsafely assumes
obj["env"].([]any)[0].(string) and will panic or miss ALT_DAGS_DIR; change the
logic in the block after yaml.Unmarshal by: validate that obj["env"] exists and
is a []any, iterate over each element, assert each entry is a string, look for a
string that starts with "ALT_DAGS_DIR=" (or split on '=' and compare key),
extract the value into altDagDir when found, and only then trim the prefix and
rebuild filename; if no ALT_DAGS_DIR is found return the existing Error
response; keep using the same variables (obj, altDagDir, filename) and preserve
the yaml.Unmarshal error handling.
🧹 Nitpick comments (1)
api/v2/api.yaml (1)
1614-1622: Constrainfilenameto allowed basename + extension.The backend only accepts
.yaml/.yml; the schema currently allows any string. Adding a pattern reduces invalid requests and clarifies the contract.📄 Suggested schema constraint
filename: type: string description: "Filename for the yaml file" + pattern: "^[a-zA-Z0-9._-]+\\.(ya?ml)$"
|
for this, config.yaml will have one more variable altDagDir under paths: which will be used for locating the alternate dags |
|
@sahalisro-blip Yes, I think that's correct. |
| |---------------------|---------|-------------| | ||
| | `DAGU_HOME` | - | Base directory that overrides all path configurations | | ||
| | `DAGU_DAGS_DIR` | `~/.config/dagu/dags` | Directory for DAG definitions | | ||
| | `DAGU_ALT_DAGS_DIR` | - | Additional directory to search for DAG definitions | |
There was a problem hiding this comment.
Please add default path
~/.config/dagu/alt_dags
There was a problem hiding this comment.
Let's keep default value empty to avoid surprises for those users who are not familiar with this config.
d8ded69 to
ec563e6
Compare
ec563e6 to
c1cb9d8
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1630 +/- ##
==========================================
- Coverage 70.18% 70.10% -0.08%
==========================================
Files 344 344
Lines 38257 38260 +3
==========================================
- Hits 26851 26824 -27
- Misses 9273 9276 +3
- Partials 2133 2160 +27
... and 9 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
now dags can only be ingest with the name.
user has to define ALT_DAGS_DIR variable in base.yaml
Spec is still working. #1609
Summary by CodeRabbit