The Simplest Way to Make Airflow and Mercurial Work Like They Should
Teams use airflow and mercurial together to run scheduled data jobs from versioned code. Mercurial stores the workflow scripts, and Airflow pulls those files to run tasks on time. This setup keeps your data jobs in sync with your code history. Every change goes through peer review before the scheduler runs it in production. When a job fails, the team can check the exact revision that caused the bug. You can also roll back to an older commit in seconds if a script breaks. How airflow and mercu
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
Teams use airflow and mercurial together to run scheduled data jobs from versioned code. Mercurial stores the workflow scripts, and Airflow pulls those files to run tasks on time.
This setup keeps your data jobs in sync with your code history. Every change goes through peer review before the scheduler runs it in production. When a job fails, the team can check the exact revision that caused the bug. You can also roll back to an older commit in seconds if a script breaks.
How airflow and mercurial share code and keys
To link airflow and mercurial, your scheduler needs a way to read the code repo. Most teams set up a background sync job or a build step. This step pulls the latest task files from the repo into the scheduler folder. The worker nodes then read those files and run the steps in order.
This data flow starts with a login step between the two systems. The sync job uses an SSH key or a user token to log in. Mercurial checks this key against its list of allowed users and roles. If the check passes, the server sends the updated script files over the network.
Permissions play a huge part in keeping this flow safe. The scheduler only needs read rights to pull the task files. It should never have write rights to push code back to the main branch. You should also tie each repo role to a single project or team folder. When you separate read roles from write roles, you stop bad scripts from changing source code.
Common failure modes and how to scope roles
Many teams take shortcuts when they first link their scheduler to their code host. A common mistake is using one shared service account for every data team. If five teams share one key, you cannot tell who pulled which code version. When that single key leaks, an attacker can read every repo on the server.
Broad tokens cause similar problems across your network. An admin might create a token with full write rights to save time. If a task script gets hijacked, that script can now delete branches or push bad code. Unlogged pulls are another big risk for growing data teams. Without clear logs, auditors cannot see which worker node pulled a sensitive script.
End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
You can fix these issues by scoping roles and network paths right away. First, give each team or pipeline its own read-only key for the repo. Set an expiration date on every key so old keys stop working on their own. Next, lock down the network path between your worker nodes and the repo server. Use firewall rules so only known scheduler nodes can reach the code host.
You also need to watch the data that flows through your task logs. Sometimes a failed code pull or task run prints private customer details into the log output. Data masking rewrites matched fields like emails, phone numbers, card numbers, or national IDs in results. This step keeps raw private records out of your shared error logs.
How to test and watch your sync pipeline
A safe code sync needs steady checks to stay healthy over time. If a sync job stalls, your workers will run old logic without warning. Your team might think a bug fix is live when the old script is still running.
Set up a simple health check that tracks the latest commit hash on the worker nodes. Compare that hash to the main branch in your code repo every few minutes. If the two hashes do not match for too long, send an alert to the team. You should also test your task scripts in a staging setup before merging them. A fast syntax check during code review catches typos before the scheduler ever pulls the file. Review your repo access logs every month to remove unused keys and stale user roles.
Govern statements and responses across databases and APIs
Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.
First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.
Frequently asked questions
How should Airflow pull new task files from Mercurial?
Use a separate sync step or a build pipeline to pull updated files on a schedule. Give that sync process a read-only key so it cannot push changes back to the repo.
Why should we avoid shared accounts for repo pulls?
Shared accounts hide who is accessing your code and make key rotation very hard. Separate read-only keys per team let you revoke one key without breaking other pipelines.
How can we keep private data out of scheduler logs?
Turn on log rules that spot sensitive patterns before the worker saves the log file. Masking rewrites emails, phone numbers, and card numbers so raw values do not sit in plain text.
Related guides
In this post