惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
小众软件
小众软件
博客园_首页
博客园 - 聂微东
V
V2EX
WordPress大学
WordPress大学
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
罗磊的独立博客
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 司徒正美
博客园 - 三生石上(FineUI控件)
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
SegmentFault 最新的问题
J
Java Code Geeks
Last Week in AI
Last Week in AI
The Cloudflare Blog
月光博客
月光博客
雷峰网
雷峰网
宝玉的分享
宝玉的分享
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Hugging Face - Blog
Hugging Face - Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
博客园 - Franky
腾讯CDC
Jina AI
Jina AI
博客园 - 叶小钗
大猫的无限游戏
大猫的无限游戏
阮一峰的网络日志
阮一峰的网络日志
量子位
爱范儿
爱范儿
美团技术团队
T
Tailwind CSS Blog
博客园 - 【当耐特】
D
Docker
IT之家
IT之家
V
Visual Studio Blog
P
Proofpoint News Feed
L
LangChain Blog
Engineering at Meta
Engineering at Meta
C
Check Point Blog
G
Google Developers Blog
Google DeepMind News
Google DeepMind News
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
Recorded Future
Recorded Future

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
What 22 CI runs taught me about the gap between local dev and production
mgoolden17-c · 2026-05-26 · via DEV Community

I built a multi-tenant DNS/email security audit app — dnslint — as a portfolio piece over a few months. FastAPI, async SQLAlchemy against Postgres, deployed to Render's free tier. The interesting part of building it wasn't the application code. It was that my local test suite passed cleanly while CI kept failing.

Not one or two failures. Twenty-two CI runs over the lifespan of the feature branch. Some were the same bug showing up twice while I tried fixes. Most were distinct bugs that my local environment was hiding from me.

This is a writeup of four of those failures. They're not glamorous bugs. They're the kind of thing that's obvious in hindsight and infuriating in the moment. The pattern across them is the same: my local dev environment was shaped differently than production in ways I hadn't noticed, and each shape difference hid a class of bug until CI or the deployed environment forced me to see it.

Bug 1: A trailing newline in DATABASE_URL

The first CI failure I want to talk about is a one-character bug. My GitHub Actions workflow defined DATABASE_URL as a multiline YAML string:

env:
  DATABASE_URL: |
    postgresql+asyncpg://user:pass@host:5432/dbname

Enter fullscreen mode Exit fullscreen mode

That pipe (|) is YAML's "literal block scalar" syntax. It preserves newlines. So the actual value of DATABASE_URL inside the CI environment wasn't postgresql+asyncpg://... — it was postgresql+asyncpg://...\n. The trailing newline broke the connection string parser in a way that produced an opaque error: "could not translate host name."

Locally, I read DATABASE_URL from a .env file via python-dotenv, which trims whitespace. So the local code path implicitly sanitized something that CI did not. My tests never had a chance to catch this because they ran against a value that had been silently cleaned before it reached SQLAlchemy.

The fix was trivial — change the YAML to a quoted single-line string. The lesson was bigger: anything that touches my code through a different runtime than the one I develop in is a potential source of bugs my tests can't catch. Environment variable parsing, file path handling, signal delivery, process startup order — every interface between my code and the world is a place where the local and deployed environments can disagree.

Bug 2: unittest.mock.patch is not thread-safe

I have a test that exercises a concurrent DNS resolver. It spawns two threads, each scanning a different domain with a different resolver IP, and asserts that each thread's resolver was correctly isolated via Python's ContextVar. Locally, it passed. In CI, it failed intermittently with an assertion that looked like this:

AssertionError: assert None == '1.1.1.1'
 where None = {'t2': '1.1.1.1'}.get('t1')

Enter fullscreen mode Exit fullscreen mode

What was happening: only one of the two threads was recording its resolver IP. The other thread's result was just gone.

I assumed at first that the ContextVar isolation was broken. It wasn't. The bug was somewhere else entirely.

The test was structured like this — each thread called unittest.mock.patch inside its own scope to install a side-effect function:

def _capture_resolver(name, ip):
    def _checks(domain):
        seen[name] = _resolver_var.get().nameservers[0]
        return _mock_checks(domain)

    with patch("dnslint_core.run_all_checks", side_effect=_checks):
        run_scan("example.com", resolver=ip)

Enter fullscreen mode Exit fullscreen mode

The problem is in what unittest.mock.patch actually does under the hood. It doesn't install a thread-local mock. It mutates a module-global attribute — literally dnslint_core.run_all_checks = mock_fn on entry, and restores the original on exit. When two threads enter their own with patch(...) blocks at overlapping times, the second thread's __enter__ overwrites the first thread's mock function while the first thread is still inside its with block.

So Thread 1's _checks closure (which would have written to seen["t1"]) got replaced by Thread 2's _checks closure (which writes to seen["t2"]) before Thread 1's run_scan call actually invoked the mock. By the time Thread 1's scan triggered the mocked function, it was running Thread 2's closure. Thread 2's result got recorded twice; Thread 1's result was never written.

Locally, the threads happened to interleave in a way that worked. In CI, on a faster runner with different scheduling, they didn't.

The fix was to install one patch outside the threads, with a single dispatcher that reads the ContextVar to figure out which resolver is active for the calling thread:

def shared_checks(domain):
    ip = _resolver_var.get().nameservers[0]
    with lock:
        seen[threading.get_ident()] = ip
    return _mock_checks(domain)

with patch("dnslint_core.run_all_checks", side_effect=shared_checks):
    t1 = threading.Thread(target=runner, args=("1.1.1.1",))
    t2 = threading.Thread(target=runner, args=("8.8.8.8",))
    t1.start(); t2.start()
    t1.join(); t2.join()

Enter fullscreen mode Exit fullscreen mode

One patch, never re-entered. The dispatcher uses the genuinely thread-local ContextVar to figure out what each thread should see.

The lesson here is about what testing tools actually do. mock.patch is the most-used mocking utility in the Python standard library. It's documented as thread-unsafe, but the docs are easy to miss, and the failure mode is statistical — the patch overwrites happen during a short window, and most test runs schedule around them by accident. Reading the source of your own tools, especially the ones that mutate global state, is the only reliable way to know what they'll do under concurrency you didn't design around. My laptop hid this for months; CI's different scheduler made it reliably visible within a few runs.

Bug 3: SQLite vs Postgres engine config

This one cost me three CI runs and an hour of confused debugging.

My SQLAlchemy engine factory looked roughly like this:

engine = create_async_engine(
    settings.database_url,
    pool_pre_ping=True,
    pool_size=5,
    max_overflow=10,
)

Enter fullscreen mode Exit fullscreen mode

That looks fine. It's the default-ish configuration for an async Postgres connection pool. The problem: my local tests use SQLite (because spinning up a Postgres container for every test run is slow), and SQLite's async driver — aiosqlite — uses a StaticPool or NullPool and raises an error if you pass pool_size or max_overflow.

Locally I'd configured the test fixtures to skip the engine factory entirely and build their own SQLite engine. So my code path that built the real engine was never exercised by my test suite. CI ran the tests against SQLite the same way, but the integration test I'd added that hit the real engine factory blew up with "invalid argument 'pool_size' for SQLite dialect."

The fix was a dialect check in the factory:

kwargs = {"pool_pre_ping": True}
if not settings.database_url.startswith("sqlite"):
    kwargs.update(pool_size=5, max_overflow=10)
engine = create_async_engine(settings.database_url, **kwargs)

Enter fullscreen mode Exit fullscreen mode

Ugly, but correct. The lesson is about test infrastructure that fakes too much. I'd designed my tests to avoid exercising the engine factory because doing so was inconvenient. That convenience came with a cost: a real code path went un-tested for the entire development cycle until CI exercised it as part of an integration test I hadn't been running locally. The bug was findable; I just hadn't been looking.

Bug 4: Migrations blocking port binding on Render

This is the bug that taught me the most about deployment, and it's the one that took me longest to recognize as a bug at all.

Render's free tier expects a web service container to bind a port within a startup timeout — I think it's ten seconds. If your container doesn't open the port in that window, Render kills it and marks the deploy as failed.

My FastAPI app's startup hook ran Alembic migrations synchronously before yielding to the Uvicorn server:

@asynccontextmanager
async def lifespan(app: FastAPI):
    command.upgrade(alembic_config, "head")  # blocks
    yield

Enter fullscreen mode Exit fullscreen mode

command.upgrade is a synchronous call. Inside an async def context, that means it blocks the entire event loop. Uvicorn can't start serving on the port until lifespan yields, which can't happen until migrations finish.

Locally this was invisible. My dev database had no migrations to run after the first time, so command.upgrade was nearly instant. On Render, the first deploy had a few hundred milliseconds of real migration work to do, and the next deploy had to acquire a connection through the free-tier database's startup latency. The combined startup time crept past Render's ten-second window. Container killed. Deploy marked failed. Render's error message was the deeply unhelpful "exited before binding to port."

The fix had three parts:

  1. Run migrations as a background task, not in the lifespan critical path:
   migration_task = asyncio.create_task(asyncio.to_thread(command.upgrade, alembic_config, "head"))

Enter fullscreen mode Exit fullscreen mode

  1. Wrap them in a Postgres advisory lock so that if I ever scale to multiple workers, they don't race each other on migrations:
   await conn.execute(text("SELECT pg_advisory_lock(12345)"))

Enter fullscreen mode Exit fullscreen mode

  1. Split the health checks: /health returns 200 immediately with migration status in the body (so Render's liveness probe is happy), and /health/ready returns 503 until migrations complete (so monitoring tools that care about real readiness get the truth).

That last part is the bit I'm proudest of, because it required me to think about what liveness and readiness actually mean. Liveness is "this container is alive and not stuck." Readiness is "this container can serve real traffic right now." Conflating them — which is the default for most apps — means your readiness signal is too coarse to be useful and your liveness signal is too strict to survive realistic startup latency.

The lesson: production-shaped constraints surface architectural decisions you didn't know you were making. I hadn't decided that migrations should block the event loop. I'd just written the most obvious code, and the obvious code happened to be wrong in a way that only mattered when the deployment environment had a startup timeout. Without that constraint, the bug would still be there, just invisible.

What I'd actually take away from this

If you read the four sections above and shrugged, you've probably been an engineer for a while and seen each of these classes of bug before. They're not novel. The novelty, for me, was in seeing all four in the same project over a short window and noticing the shared shape.

The pattern: every one of these bugs existed because my development environment was different from production in a way I hadn't accounted for. The differences were in places I'd been treating as invisible plumbing:

  • Environment variable parsing (Bug 1)
  • Process scheduling and concurrency (Bug 2)
  • Database dialect (Bug 3)
  • Startup sequencing and runtime constraints (Bug 4)

These aren't application concerns. They're environment concerns, and I'd been writing code as if the environment was a stable layer underneath my application — which it isn't. The environment is part of the code path. My local environment was running a slightly different program than my production environment, and the differences between those programs were exactly where bugs lived.

What I'd do differently next time:

  1. Pick one production-shaped layer to run locally, early. I picked SQLite for local tests, which was a convenience I paid for in Bug 3. A Postgres container via Docker Compose costs me thirty seconds at startup and would have caught the engine config bug on my laptop instead of in CI.

  2. Treat CI failures as data, not as obstacles. I caught myself, more than once, trying to "make CI green" rather than understand why it was red. The pattern of "this passed locally so the CI must be misconfigured" is a tell — it usually means I'm wrong, not the CI.

  3. Write the integration test before the unit test. Unit tests confirm that the function I just wrote does what I think. Integration tests confirm that the system I just wrote can actually start and serve a request. Bug 4 would have been caught by a smoke test against the real Render-shaped startup path, weeks before I noticed it on a deploy.

  4. Health checks aren't a checkbox; they're an interface design problem. Liveness vs readiness is a real distinction. So is "responds to TCP" vs "is functionally serving requests." The right split depends on what's consuming the signal.

CI was supposed to be the boring last step before a deploy. Instead, it was the most informative debugging tool I had — better than my local IDE, better than my test suite, better than reading logs after the fact. Every red run was a free lesson, and most of them taught me something about my own assumptions that I wouldn't have caught any other way.

If you're building a portfolio project and find your CI is flaky or your deploys are weird, don't paper over it. The annoyance is the signal.


The full project is at github.com/mgoolden17-cyber/dnslint with a live demo and a full known-issues log. I built this while finishing my cybersecurity degree at SUNY Canton; I write occasionally about engineering practice.