Webhook icon
WorkingDirectory icon
Clone icon
Script icon
Docker icon
Switch icon
Log icon
SlackIncomingWebhook icon
If icon
Fail icon

Git LFS Pointer Integrity and Raw Binary Quota Gate

Audit Git LFS pointer integrity, prevent raw binary repository bloat, and gate CI/CD merges using Kestra with automated Slack triage and migration hints.

Categories
Infrastructure

Prevent Git repository bloat and broken deployment pipelines by validating Git LFS pointer integrity and enforcing binary size quotas before merge. In data engineering, machine learning, and infrastructure-as-code repositories, developers frequently introduce large files such as model weights (.safetensors, .onnx), Parquet partitions, binary artifacts, or database snapshots.

When contributors commit large assets without configuring Git Large File Storage (LFS), those files enter the standard Git object graph permanently. Every subsequent clone downloads the historical blobs, drastically increasing checkout durations and threatening remote hosting quota limits (such as GitHub's 100 MB hard limit). Conversely, when developers commit malformed LFS pointer stubs or commit raw binary bytes into paths matched by .gitattributes without running the Git LFS clean filter, downstream deployment containers and automated runners suffer from missing object errors or inference startup crashes.

This blueprint implements an automated compliance gate that clones the repository, parses .gitattributes tracking patterns, validates that all LFS pointers adhere strictly to the Git LFS v1 specification (valid SHA-256 OID and byte size attributes), and audits remaining repository files against a configurable raw blob threshold (default: 50 MB). If violations are detected, the workflow formats a actionable Slack incident card with the exact git lfs migrate import remediation command and halts the pipeline via io.kestra.plugin.core.execution.Fail.

How it works

  1. git_webhook listens for incoming push webhooks from GitHub or GitLab and takes the repository clone URL and ref from the payload; for manual runs the git_repository_url and git_branch inputs are used.
  2. repository_workspace (io.kestra.plugin.core.flow.WorkingDirectory) mounts an isolated filesystem workspace shared between the Git clone task and the Python inspection engine.
  3. clone_repository (io.kestra.plugin.git.Clone) checks out the target repository and branch into the shared workspace.
  4. audit_lfs_and_binary_blobs (io.kestra.plugin.scripts.python.Script) executes inside a Python container to:
    • Parse .gitattributes to identify all file patterns designated for Git LFS tracking (filter=lfs, diff=lfs, merge=lfs).
    • Traverse the repository filesystem, ignoring .git metadata and build caches.
    • Verify that every file containing Git LFS header signatures strictly conforms to the v1 specification with a valid 64-character hexadecimal SHA-256 OID and numeric size.
    • Detect "untransformed" files: files that match .gitattributes LFS glob patterns but were checked in as raw binaries because local LFS pre-commit hooks were bypassed.
    • Identify any untracked files exceeding max_raw_blob_mb (default: 50 MB).
    • Emit structured outputs including violation counts, offending file paths, and copy-paste remediation commands.
  5. evaluate_audit_verdict (io.kestra.plugin.core.flow.Switch) routes execution according to the audit verdict:
    • COMPLIANT: Logs verification details confirming repository cleanliness and pointer spec compliance.
    • UNTRACKED_LARGE_BLOB: Posts a Slack alert with the list of bloated files and the exact git lfs migrate import command; halts execution via fail_on_blob_quota_breach (io.kestra.plugin.core.execution.Fail) if enforce_gate is true.
    • UNTRANSFORMED_LFS_FILE: Alerts Slack that raw binary bypassed Git LFS clean filters and halts execution.
    • CORRUPTED_POINTER: Dispatches a Slack notification detailing corrupted pointer checksums and halts execution.

What you get

  • Automated prevention of repository bloat caused by accidental commits of datasets, weights, or archives.
  • Deep validation of Git LFS pointer files preventing silent 404 missing object failures in production deployments.
  • Detection of bypassed LFS filters where raw binaries were committed into LFS-tracked paths.
  • Turnkey remediation instructions: automatically generated git lfs migrate import commands tailored to the detected file extensions.
  • Clear pass/fail gating for CI/CD pipelines and pull request approval workflows.

Who it's for

  • Platform and DevOps Engineers managing Git infrastructure and remote storage costs.
  • Machine Learning Engineers deploying models and weights from version-controlled repositories.
  • Data Platform Engineers handling data contracts, Parquet schemas, and embedded test fixtures.
  • Release Managers guarding production build stability against corrupted pointer stubs.

Why orchestrate this with Kestra

Validating large binary hygiene via local pre-commit hooks is fragile because hooks can be skipped with --no-verify, and local developer machines often lack uniform Git LFS installations. Centralizing this check in Kestra guarantees:

  • Uniform Policy Enforcement: Every pull request and release branch is audited in an identical, sandboxed container environment.
  • Declarative Flow Control: The combination of WorkingDirectory, Clone, Script, Switch, and Fail provides clear visual execution topology and auditable historical records.
  • Contextual Incident Response: Slack alerts provide developers with the exact command needed to fix the history without requiring manual support tickets.

Prerequisites

  • A Kestra instance with Docker task runner capability enabled for containerized script execution.
  • Network connectivity from Kestra workers to the target Git hosting provider (e.g., GitHub, GitLab).
  • A Slack Incoming Webhook URL for alert routing.

Secrets

  • GIT_WEBHOOK_KEY: Secret authentication key securing the incoming webhook trigger endpoint.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook URL used to dispatch quota breach notifications and migration advice.

Quick start

  1. In your Kestra namespace, configure the required secrets: GIT_WEBHOOK_KEY and SLACK_WEBHOOK_URL.
  2. Import this blueprint into your Kestra workspace.
  3. Run an initial test execution via the Kestra UI with the required git_repository_url input pointing to your repository.
  4. Configure your Git hosting service (e.g., GitHub repository Settings -> Webhooks) to send pull request and push events to the git_webhook URL.

How to extend

  • Private Repository Authentication: For private repositories, configure username and password on io.kestra.plugin.git.Clone using {{ secret('GITHUB_PAT') }}.
  • Pull Request Comments: Add an io.kestra.plugin.github.issues.Comment task under UNTRACKED_LARGE_BLOB to post the migration command directly as a comment on the offending pull request.
  • LFS Storage Reachability Check: Extend the Python audit task to issue an HTTP HEAD request to your LFS backend (AWS S3, Azure Blob, or GitHub LFS) using the parsed OID to verify that the binary blob actually exists on the remote storage server.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.