Skip to content

feat: add definition page link to DAG run details header#1977

Merged
yottahmd merged 2 commits intomainfrom
feat/dag-run-definition-link
Apr 9, 2026
Merged

feat: add definition page link to DAG run details header#1977
yottahmd merged 2 commits intomainfrom
feat/dag-run-definition-link

Conversation

@yottahmd
Copy link
Copy Markdown
Collaborator

@yottahmd yottahmd commented Apr 9, 2026

Summary

  • Adds a sourceFileName field to the DAG run details API response, derived from the DAG run's source file path (only set when the source file still exists on disk)
  • Displays a "Definition" link next to the DAG name in the DAG run status page header, navigating to /dags/{sourceFileName}/
  • Allows users to quickly jump from a DAG run to its DAG definition page without manual navigation

Test plan

  • Verify sourceFileName is returned in the DAG run details API response when the source file exists
  • Verify sourceFileName is absent when the source file no longer exists on disk
  • Verify the "Definition" link appears in the DAG run header and navigates to the correct definition page
  • Verify the link does not appear for DAG runs without a usable source file

Summary by CodeRabbit

  • New Features
    • DAG run details now display a "Definition" link that navigates to the source DAG definition file when available.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

The changes add a new optional SourceFileName field to the DAGRunDetails API response, exposed in the schema and generated code. Service logic derives this filename from DAG attempt data when the source file exists under the configured DAGs directory. The UI component conditionally renders a navigation link to the DAG definition when the filename is present.

Changes

Cohort / File(s) Summary
API Schema & Code Generation
api/v1/api.yaml, api/v1/api.gen.go, ui/src/api/v1/schema.ts
Added optional sourceFileName: string property to DAGRunDetails schema and updated corresponding TypeScript interface and generated API code.
Service Logic
internal/service/frontend/api/v1/dagruns.go
Refactored dagRunSpecFromFile helper into dagRunSourceInfo to derive both specFromFile bool and sourceFileName string. Returns source filename only when DAG source file exists under configured DAGs directory and is provided as basename without extension.
UI Component
ui/src/features/dag-runs/components/dag-run-details/DAGRunHeader.tsx
Updated header to conditionally render a "Definition" link when sourceFileName is present, with navigation to /dags/<encoded sourceFileName>/ URL.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly describes the main change: adding a definition page link to the DAG run details header, which is the primary user-facing feature across all modified files.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dag-run-definition-link

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.

@yottahmd yottahmd force-pushed the feat/dag-run-definition-link branch from 5562382 to 93e7ca8 Compare April 9, 2026 06:15
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)
api/v1/api.yaml (1)

8261-8263: Prefer reusing DAGFileName schema for sourceFileName

Using a plain string weakens the contract. Consider referencing #/components/schemas/DAGFileName so validation and route expectations stay consistent with other DAG filename fields.

♻️ Proposed schema tweak
             sourceFileName:
-              type: string
+              $ref: "#/components/schemas/DAGFileName"
               description: "File name of the source DAG definition, derived from the DAG-run's source file path. Only set when the source file still exists on disk. Can be used to navigate to the DAG definition page."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@api/v1/api.yaml` around lines 8261 - 8263, Replace the inline plain string
schema for sourceFileName with a reference to the existing DAGFileName component
(use $ref: '#/components/schemas/DAGFileName') so the field reuses the shared
DAG filename contract; keep the current description text and any
nullable/required semantics intact when swapping type:string for the $ref.
Ensure the symbol sourceFileName in the API YAML now points to the shared
DAGFileName schema to maintain consistent validation and route expectations.
🤖 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/service/frontend/api/v1/dagruns.go`:
- Around line 3263-3265: Replace the fragile prefix check that uses
strings.HasPrefix(absSource, absDAGsDir+string(filepath.Separator)) with a
containment test using filepath.Rel: call filepath.Rel(absDAGsDir, absSource)
and treat the source as inside the DAGs dir if the returned relative path does
not start with ".." and no error occurred; update the branch that currently
returns (true, "") to use this new check so sourceFileName is only suppressed
when the file is truly outside absDAGsDir.

---

Nitpick comments:
In `@api/v1/api.yaml`:
- Around line 8261-8263: Replace the inline plain string schema for
sourceFileName with a reference to the existing DAGFileName component (use $ref:
'#/components/schemas/DAGFileName') so the field reuses the shared DAG filename
contract; keep the current description text and any nullable/required semantics
intact when swapping type:string for the $ref. Ensure the symbol sourceFileName
in the API YAML now points to the shared DAGFileName schema to maintain
consistent validation and route expectations.
🪄 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: a90269b0-aec7-4f00-b881-5d31439edb82

📥 Commits

Reviewing files that changed from the base of the PR and between 867d606 and 93e7ca8.

📒 Files selected for processing (5)
  • api/v1/api.gen.go
  • api/v1/api.yaml
  • internal/service/frontend/api/v1/dagruns.go
  • ui/src/api/v1/schema.ts
  • ui/src/features/dag-runs/components/dag-run-details/DAGRunHeader.tsx

Comment thread internal/service/frontend/api/v1/dagruns.go Outdated
…chema

Address PR review comments:
- Replace brittle strings.HasPrefix containment check with filepath.Rel
  to correctly handle edge cases like DAGsDir == "/"
- Reference shared DAGFileName schema for sourceFileName in OpenAPI spec
  instead of inline plain string type
@yottahmd yottahmd merged commit 9d80ee8 into main Apr 9, 2026
5 checks passed
@yottahmd yottahmd deleted the feat/dag-run-definition-link branch April 9, 2026 08:53
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