Skip to content

DM-54689: Surface commit_sha and web_url on dashboard-template binding response #281

@jonathansick

Description

@jonathansick

Metadata

Field Value
Parent PRD #232
Jira Key DM-54689
Jira URL https://rubinobs.atlassian.net/browse/DM-54689
Task Order 32
Type AFK
Blocked by None
Parallel with #279, #280, #282 (peers in this batch)
Branch tickets/DM-54689-github-webhook

Origin

Follow-up suggestion

What to build

The dashboard-template binding response (the model returned by GET/PUT /orgs/{org}/dashboard-template and the project-override variant) does not currently expose either:

  • the commit SHA of the most recent successful sync, or
  • a web URL that links to the template's location in the GitHub browsing UI.

Both are useful for diagnostics and for letting an admin click through from the binding to verify configuration.

commit_sha is already stored — dashboard_github_templates.commit_sha (src/docverse/dbschema/dashboard_github_template.py:50), reachable from the binding via the github_template_id FK. web_url is derivable from binding fields directly (github_owner, github_repo, github_ref, root_path) and does not require a successful sync to have happened.

Approach sketch

  • Extend the binding response model (in handlers/orgs/models.py, the dashboard-template binding response near the org/project response models) with two fields:
    • commit_sha: str | None — populated from binding.github_template.commit_sha when the FK is set; None until the first successful sync.
    • web_url: str — always present once a binding exists. Derived from (github_owner, github_repo, github_ref, root_path).
  • Add a small helper in storage/github/ that builds the GitHub browse URL: https://github.com/{owner}/{repo}/tree/{ref} when root_path is /, otherwise append the path (handle leading slash carefully). Co-locate with storage/github/tree_fetcher.py so all GitHub-URL knowledge stays in one place.
  • Update from_domain on the response model to call the helper and to read commit_sha off the linked content row.
  • Make sure both the org-default and project-override binding responses get both fields (single shared response model or two — match whatever the existing models do).

Acceptance criteria

  • Binding response includes commit_sha: str | NoneNone before first successful sync, set to the latest synced commit afterwards
  • Binding response includes web_url: str — present whenever a binding exists, regardless of sync state
  • web_url is correct for both root_path == "/" (omits the path segment) and a non-root root_path (appends without double slashes)
  • GitHub URL helper lives in storage/github/ and has unit tests covering root vs subdirectory paths and refs that include / (e.g. release/1.0)
  • Existing handler tests for GET/PUT /orgs/{org}/dashboard-template and the project-override variant assert the new fields

Metadata

Metadata

Assignees

No one assigned

    Labels

    prd-taskImplementation task from a PRD

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions