<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: spran wiki</title>
    <description>The latest articles on DEV Community by spran wiki (@spran1).</description>
    <link>https://dev.to/spran1</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4175491%2F93c561f5-850e-4092-aa4f-ca110f39897d.png</url>
      <title>DEV Community: spran wiki</title>
      <link>https://dev.to/spran1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/spran1"/>
    <language>en</language>
    <item>
      <title>robots.txt can't block AI crawlers, but something can</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Sat, 21 Nov 2026 14:01:52 +0000</pubDate>
      <link>https://dev.to/spran1/robotstxt-cant-block-ai-crawlers-but-something-can-21oj</link>
      <guid>https://dev.to/spran1/robotstxt-cant-block-ai-crawlers-but-something-can-21oj</guid>
      <description>&lt;p&gt;Your robots.txt file does not block anyone. It is a text file full of polite requests, and the standard behind it says so in plain words. RFC 9309, the IETF specification for the Robots Exclusion Protocol, states that the rules "are not a form of access authorization."&lt;/p&gt;

&lt;p&gt;That matters more than it used to. Your site is now read by AI crawlers that collect training data, search bots that decide whether you appear in chatbot answers, and fetchers that pull your pages when a user asks a question. If you want a say in any of that, it helps to know what robots.txt actually does, who is listening, and what to add when a request is not enough.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1d46ntoxvaqlijfc3ade.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F1d46ntoxvaqlijfc3ade.png" alt="Diagram titled Who actually stops an AI crawler, subtitled robots.txt asks while your CDN, server or app decides. Top path, left to right: an AI crawler sends the request, with GPTBot, ClaudeBot, OAI-SearchBot, Claude-SearchBot, ChatGPT-User and others listed; a middle box named Where a request can stop lists CDN, WAF, origin server or app blocking by user agent or IP range, or requiring a login, as what can stop a request; the path ends at your content. Below the crawler, off the main path, a box named robots.txt, consulted separately says cooperative crawlers fetch this file on their own and choose whether to honor it, that RFC 9309 says the rules are not a form of access authorization, and that anyone can skip it; a connector marked fetched separately links the crawler to it. A note lists the separate switches: training crawlers GPTBot and ClaudeBot, search crawlers OAI-SearchBot and Claude-SearchBot, user-triggered fetches ChatGPT-User and Claude-User, and says you can allow one purpose and disallow another. The footer says robots.txt states your preference and enforcement lives on the request path." width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  robots.txt is a convention, not a control
&lt;/h2&gt;

&lt;p&gt;RFC 9309 formalized the Robots Exclusion Protocol in 2022. The spec says crawlers are requested to honor the rules in your file. Requested. Nothing puts the file between a crawler and your server: a cooperative crawler fetches robots.txt separately and decides for itself whether to comply, and nothing in the protocol can stop a request. Well-behaved crawlers comply because their operators choose to comply. Cloudflare's documentation puts it directly: robots.txt directives are voluntary, and crawlers can ignore them.&lt;/p&gt;

&lt;h2&gt;
  
  
  The AI labs split their crawling into separate bots
&lt;/h2&gt;

&lt;p&gt;OpenAI documents three user agents. GPTBot crawls content that may be used to train its foundation models, and disallowing GPTBot tells OpenAI your content should not be used for that training. OAI-SearchBot is used to surface websites in ChatGPT search results; OpenAI says sites that opt out of it will not be shown in ChatGPT search answers, though they can still appear as navigational links. ChatGPT-User fetches a page when a user asks ChatGPT something; because these requests are user-initiated, OpenAI notes that robots.txt rules may not apply. The settings are independent, and OpenAI says search can take about 24 hours to adjust to a robots.txt update.&lt;/p&gt;

&lt;p&gt;Anthropic documents a similar split. ClaudeBot collects web content that could contribute to model training, Claude-SearchBot works on search result quality, and Claude-User handles fetches directed by a user's question. Anthropic says its bots honor robots.txt directives, supports the non-standard Crawl-delay extension, and asks you to set the rules on every subdomain you want covered. As of October 30, 2026, Anthropic has also begun recognizing a machine-readable signal, based on IETF draft work, that lets a site express a "no AI training" preference, with the rollout happening over time. A robots.txt rule that names ClaudeBot directly takes priority over that general signal.&lt;/p&gt;

&lt;p&gt;The practical consequence: "allow AI" and "block AI" are not your only options. You can disallow the training crawlers while allowing the search crawlers, so your pages can still be cited in chatbot answers. That split is the part most site owners miss.&lt;/p&gt;

&lt;h2&gt;
  
  
  When a request needs teeth, enforce it on the request path
&lt;/h2&gt;

&lt;p&gt;If you want certainty instead of cooperation, the block has to happen on the request path itself: a CDN or WAF rule, your origin server, or your app requiring a login. Cloudflare's AI Crawler and Agent access policies are the clearest example. You set an action for each behavior (Search, Agent, Training), and the Block action stops matching requests at Cloudflare's edge. Two details are worth knowing. The Training behavior also offers a Disallow action that only writes robots.txt directives, which stay voluntary unless you enable the option that additionally blocks AI training crawlers at the edge. And for new domains, all three behaviors default to Allow, so doing nothing is itself a choice.&lt;/p&gt;

&lt;p&gt;You can do the same thing without Cloudflare: deny requests by user agent in your server configuration, or block the published IP ranges the labs maintain (OpenAI publishes a JSON list per bot). One caveat from Anthropic's documentation: blocking their crawler IPs can impede their ability to read your robots.txt, so they warn it may not work as a persistent opt-out on its own. My advice: keep robots.txt as the stated preference, and treat request-path rules as the enforcement layer, not a replacement for the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  The file that does the opposite: llms.txt
&lt;/h2&gt;

&lt;p&gt;Blocking is only half of the decision. The llms.txt proposal, first published in 2024 and updated to v2 in 2026, suggests a markdown file on your site that gives agents concise, expert-level information plus links to markdown versions of your pages. It is a proposal, not a standard, but it notes that thousands of sites now publish one, and OpenAI, Anthropic and Gemini publish their own. If you want AI assistants to describe your product accurately, this is the constructive counterpart to robots.txt: one file states what stays out, the other helps what comes in get read correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I would approach it
&lt;/h2&gt;

&lt;p&gt;This part is advice, not documentation. Ask three questions. Do I want my content in training datasets? Do I want it in AI search answers? Do I want user-triggered fetches to work? Then write one robots.txt group per bot to match your answers. If "no" needs to mean "no," put a real block behind it, whether that is a CDN rule, a server rule or a login wall. If you want to be read well, consider an llms.txt. None of it is permanent; you can change the file tomorrow.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this adds up to
&lt;/h2&gt;

&lt;p&gt;robots.txt is where you state your preference, and the standard itself says it is not access authorization. The major AI labs document separate bots for training, search and user-triggered fetches, so you can choose per purpose. Only a control on the request path, a CDN rule, your server configuration or a login, can actually stop a request. And llms.txt exists for the opposite goal: helping agents read what you want them to read.&lt;/p&gt;

&lt;p&gt;The next step is small. Open your robots.txt, decide what it should say about each bot, and decide whether your "no" needs enforcement behind it.&lt;/p&gt;

&lt;p&gt;Source pages: &lt;a href="https://www.rfc-editor.org/rfc/rfc9309" rel="noopener noreferrer"&gt;RFC 9309: Robots Exclusion Protocol&lt;/a&gt;, &lt;a href="https://developers.openai.com/api/docs/bots" rel="noopener noreferrer"&gt;OpenAI crawlers&lt;/a&gt;, &lt;a href="https://support.claude.com/en/articles/8896518-does-anthropic-crawl-data-from-the-web-and-how-can-site-owners-block-the-crawler" rel="noopener noreferrer"&gt;Anthropic's crawler documentation&lt;/a&gt;, &lt;a href="https://developers.cloudflare.com/bots/additional-configurations/block-ai-bots/" rel="noopener noreferrer"&gt;Cloudflare AI Crawler and Agent access policies&lt;/a&gt;, &lt;a href="https://llmstxt.org/" rel="noopener noreferrer"&gt;The llms.txt proposal&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I write about startups and AI at &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;startupwiki.substack.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Cover photo: &lt;a href="https://unsplash.com/photos/a-no-entry-sign-is-attached-to-a-gate-yOJg-L0y7lM" rel="noopener noreferrer"&gt;Phil Hearing on Unsplash&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>seo</category>
      <category>security</category>
    </item>
    <item>
      <title>7 things to check before an AI coding agent touches your repo</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Fri, 20 Nov 2026 14:01:26 +0000</pubDate>
      <link>https://dev.to/spran1/7-things-to-check-before-an-ai-coding-agent-touches-your-repo-1emh</link>
      <guid>https://dev.to/spran1/7-things-to-check-before-an-ai-coding-agent-touches-your-repo-1emh</guid>
      <description>&lt;p&gt;If you let an AI coding agent work in a repository, it acts through some account or token. Whatever that identity can do, the agent can do. GitHub's docs say a personal access token has the same capabilities as its owner, limited by the scopes or permissions it was granted.&lt;/p&gt;

&lt;p&gt;So the question is not whether the agent is smart. It is what your repository allows before anything reaches production. Here are seven settings worth checking on GitHub. Each one comes from GitHub's own documentation, and the docs do not mention AI agents. Applying them to agents is my advice. Availability varies by plan and repository visibility, so check your own settings.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fahm22sf24a9ec1hrw95l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fahm22sf24a9ec1hrw95l.png" alt="Diagram titled Seven checks along the path of an agent change. Four stages left to right: Credential (check 5, fine-grained token limited to chosen repositories and permissions), Push (check 4, push protection blocks detected secrets, check who can bypass), Pull request (checks 1 to 3: required reviews, admin bypass rule scope, CODEOWNERS), Workflow run (checks 6 and 7: GITHUB_TOKEN permissions, environment rules and secrets). A box says to open repository settings, answer each check as on, off or not available on your plan, and fix the gaps. A note says each check covers one point on the path and no single check covers all of it, and that settings vary by plan and visibility." width="800" height="490"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Require pull request reviews on the default branch
&lt;/h2&gt;

&lt;p&gt;With a branch protection rule, repository admins can require a number of approving reviews before a merge. GitHub's docs say that once required reviews are on, collaborators can only change the protected branch through an approved pull request.&lt;/p&gt;

&lt;p&gt;You can also dismiss stale approvals when new commits change the diff. That matters if an agent keeps pushing to a branch after a human approved it.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Know who the default branch rule applies to
&lt;/h2&gt;

&lt;p&gt;By default, a branch protection rule does not apply to people with admin permissions, or to custom roles with the "bypass branch protections" permission. You can opt in to applying it to them as well.&lt;/p&gt;

&lt;p&gt;If the agent runs as an admin account, the default rule may not stop it. Run it as a lower-privilege identity, or turn on the option that includes admins. That second part is my advice.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Use CODEOWNERS for the files that matter
&lt;/h2&gt;

&lt;p&gt;A CODEOWNERS file names the people or teams responsible for parts of the code. Per the docs, owners are requested for review automatically when a pull request touches their files. Admins can also require code owner approval before merging.&lt;/p&gt;

&lt;p&gt;Two details from the docs are easy to miss. The file must exist on the base branch of the pull request. And owners must have write permission, or they are not requested.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Turn on push protection for secrets
&lt;/h2&gt;

&lt;p&gt;Push protection blocks a push when it detects a secret, before the secret reaches the repository. The docs list partner patterns, generic patterns such as private keys and database connection strings, and custom patterns.&lt;/p&gt;

&lt;p&gt;Two limits to note. Generic patterns have to be enabled in your security settings. And by default, anyone with write access can bypass a block by giving a reason. An agent that can write to the repository may be able to do the same, so review who can bypass.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Give the token the smallest reach you can
&lt;/h2&gt;

&lt;p&gt;GitHub recommends fine-grained personal access tokens over classic ones whenever possible. Per the docs, a fine-grained token can be limited to specific repositories and given specific permissions, and organization owners can require approval for them.&lt;/p&gt;

&lt;p&gt;The docs also say fine-grained tokens cannot do everything classic tokens can, so check that your use case works. If it does, a token for one repository with only the permissions the task needs is a smaller target than a classic token with broad scopes.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Limit what the workflow token can do
&lt;/h2&gt;

&lt;p&gt;GitHub Actions gives each workflow run a GITHUB_TOKEN. The docs say an action can reach it through the &lt;code&gt;github.token&lt;/code&gt; context even if the workflow never passes it in, and recommend limiting its permissions to the minimum needed.&lt;/p&gt;

&lt;p&gt;You set this with a &lt;code&gt;permissions&lt;/code&gt; block in the workflow. If an agent can edit workflow files, then the branch rules and reviews from checks 1 to 3 are what keep a permissions change from merging unseen. That connection is my reasoning, not a statement from the docs.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Keep deploy secrets behind an environment
&lt;/h2&gt;

&lt;p&gt;An environment can have protection rules, and a job that uses it must pass them before it runs or reads the environment's secrets. Rules include required reviewers (the docs say up to 6, and one approval is enough), a wait timer, and limits on which branches can deploy. You can also prevent the person who triggered a run from approving it.&lt;/p&gt;

&lt;p&gt;Two caveats from the docs. Environments on GitHub Free are only available for public repositories. And a workflow that references an environment that does not exist creates it with no protection rules, so create and configure it first.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this adds up to
&lt;/h2&gt;

&lt;p&gt;Each check covers a different point on the path: the credential, the push, the pull request and the workflow run. No single one covers all of it.&lt;/p&gt;

&lt;p&gt;A short way to use this list: open the repository's settings and answer each of the seven with "on", "off" or "not available on our plan". The answers tell you what stands between an agent's change and your production secrets. Fixing the gaps can start with check 1.&lt;/p&gt;

&lt;p&gt;Source pages: &lt;a href="https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches" rel="noopener noreferrer"&gt;About protected branches&lt;/a&gt;, &lt;a href="https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners" rel="noopener noreferrer"&gt;About code owners&lt;/a&gt;, &lt;a href="https://docs.github.com/en/code-security/secret-scanning/introduction/about-push-protection" rel="noopener noreferrer"&gt;Push protection&lt;/a&gt;, &lt;a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens" rel="noopener noreferrer"&gt;Managing your personal access tokens&lt;/a&gt;, &lt;a href="https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication" rel="noopener noreferrer"&gt;Use GITHUB_TOKEN for authentication in workflows&lt;/a&gt;, &lt;a href="https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-deployments/managing-environments-for-deployment" rel="noopener noreferrer"&gt;Managing environments for deployment&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I write about startups and AI at &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;startupwiki.substack.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Cover photo: &lt;a href="https://unsplash.com/photos/laptop-screen-displaying-code-with-colorful-background-xHS2Gbjw4OI" rel="noopener noreferrer"&gt;Daniil Komov on Unsplash&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>github</category>
      <category>security</category>
      <category>devops</category>
    </item>
    <item>
      <title>Have you ever restored your database backup?</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Thu, 19 Nov 2026 14:00:36 +0000</pubDate>
      <link>https://dev.to/spran1/have-you-ever-restored-your-database-backup-aoo</link>
      <guid>https://dev.to/spran1/have-you-ever-restored-your-database-backup-aoo</guid>
      <description>&lt;p&gt;A backup job that reports success tells you a file was written. It does not tell you the file can bring your database back. A restore into a safe place, followed by checks, is how you learn that. One drill tests that one backup; it does not prove every backup, or every kind of failure, is covered.&lt;/p&gt;

&lt;p&gt;This post describes a small restore drill. The details differ by engine and backup type, so I name the mode for each claim. The examples use PostgreSQL and Amazon RDS because both have clear official documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Know which kind of backup you have
&lt;/h2&gt;

&lt;p&gt;"We have backups" can mean three different things.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;logical dump&lt;/strong&gt; from &lt;code&gt;pg_dump&lt;/code&gt; is a set of SQL commands or an archive that recreates one database. The &lt;a href="https://www.postgresql.org/docs/current/backup-dump.html" rel="noopener noreferrer"&gt;PostgreSQL docs&lt;/a&gt; say &lt;code&gt;pg_dump&lt;/code&gt; dumps a single database and does not include roles or tablespaces, because those are cluster-wide. &lt;code&gt;pg_dumpall&lt;/code&gt; covers the whole cluster, including role and tablespace definitions, but restoring it needs superuser access.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;base backup plus archived WAL&lt;/strong&gt; supports point-in-time recovery. According to the &lt;a href="https://www.postgresql.org/docs/current/continuous-archiving.html" rel="noopener noreferrer"&gt;continuous archiving docs&lt;/a&gt;, recovery needs a continuous sequence of archived WAL files reaching back at least to the start of the base backup, and this method restores a whole cluster, not a subset.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;managed service backup&lt;/strong&gt; is the provider's feature. For Amazon RDS, the &lt;a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_PIT.html" rel="noopener noreferrer"&gt;point-in-time restore docs&lt;/a&gt; say a restore creates a new DB instance and does not modify the source. Those docs also say RDS uploads transaction logs to S3 every five minutes, and that the &lt;code&gt;LatestRestorableTime&lt;/code&gt; field shows how far forward you can restore.&lt;/p&gt;

&lt;p&gt;Each type fails in a different way, so each needs a drill that matches it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The drill, in five checks
&lt;/h2&gt;

&lt;p&gt;Run this on a scratch environment, never on production. A new database, a new instance, or a throwaway server is fine. The point is to prove the restore path without risking live data.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Does it restore at all?
&lt;/h3&gt;

&lt;p&gt;Start from the backup as it exists in storage, not from a copy you made for the test. For a logical dump, create an empty database and load it. &lt;a href="https://www.postgresql.org/docs/current/app-pgrestore.html" rel="noopener noreferrer"&gt;pg_restore&lt;/a&gt; handles archive formats; plain SQL dumps load through &lt;code&gt;psql&lt;/code&gt;. For RDS, restore to a new instance. For a base backup, replay the archived WAL on a separate machine.&lt;/p&gt;

&lt;p&gt;Watch for errors. A restore that finishes with warnings you never read is not a pass.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. How long did it take?
&lt;/h3&gt;

&lt;p&gt;Write down the elapsed time. Then compare it with the downtime your business can tolerate. This is my advice, not a rule from the docs: if the number surprises you, you have learned something cheap. Larger databases generally take longer to restore, and loading data is not always the last step, so time the whole path to a usable database, not only the first command.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Does the data check out?
&lt;/h3&gt;

&lt;p&gt;Pick checks you can verify without guessing. Counts alone can hide missing recent writes, so include one check on the newest data. These are sampled checks. They can reveal a gap, but passing them does not prove the whole restore is complete, so add checks that fit your own data. Compare row counts for a few important tables with the source. Look up the newest record you expect to see and confirm it is there. For point-in-time recovery, restore to a specific target time and confirm the data matches that moment.&lt;/p&gt;

&lt;p&gt;This is also where the RDS &lt;code&gt;LatestRestorableTime&lt;/code&gt; value earns its place. If it is far behind, your recovery point is further back than you assumed.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Is everything the app needs present?
&lt;/h3&gt;

&lt;p&gt;A database is more than tables. The PostgreSQL docs note that after restoring a backup it is wise to run &lt;code&gt;ANALYZE&lt;/code&gt; on each database so the query optimizer has useful statistics. A dump from &lt;code&gt;pg_dump&lt;/code&gt; also leaves out roles, so a restored database may not have the accounts your app connects with.&lt;/p&gt;

&lt;p&gt;Point a copy of your application at the restored database in a test environment. If it cannot log in or a query fails, you found a gap before an incident did. Keep that environment isolated from production integrations. A restored copy may hold real customer emails and live service keys, so turn off outbound email, background jobs, and payment calls, or swap in test credentials, before the app starts. This is my advice, so adapt it to what your app connects to.&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Where do the backups live?
&lt;/h3&gt;

&lt;p&gt;Check which account, region, and credentials hold them. A backup that sits next to the primary, under the same credentials, can be lost along with it. Whether that matters depends on your risk. Decide on purpose.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9de7xj3wexlwt79yc4y3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9de7xj3wexlwt79yc4y3.png" alt="A restore drill flow. A backup in storage is restored into a scratch environment, never production. Five checks follow: it restores without errors, restore time is recorded, the data is validated with sampled checks, the app can use it, and backup location is reviewed. A note says the exact steps depend on the backup type: logical dump, base backup with WAL, or managed snapshot." width="800" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep it small and repeatable
&lt;/h2&gt;

&lt;p&gt;Do not wait for a perfect process. Perfect is not the goal, a known-good path is. Start with a simple checklist. Write down the commands you ran, the time they took, and what you had to look up. The next person, possibly you in a bad hour, will start from that page instead of from nothing.&lt;/p&gt;

&lt;p&gt;Then decide how often to repeat it. That depends on how fast your data and schema change. A drill after a major migration or a change to your backup setup is a reasonable trigger.&lt;/p&gt;

&lt;p&gt;The main takeaway: a backup stays unverified until you restore it and check the result. Pick the backup type you actually use, restore it into a scratch environment, time it, check the data, and write down what you learned.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo (equipment racks) by &lt;a href="https://unsplash.com/photos/a-rack-of-servers-in-a-server-room-2JJ3wBHu4_0" rel="noopener noreferrer"&gt;Kevin Ache&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>database</category>
      <category>devops</category>
      <category>backend</category>
    </item>
    <item>
      <title>7 HTTP security headers worth checking on your SaaS</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Wed, 18 Nov 2026 14:01:17 +0000</pubDate>
      <link>https://dev.to/spran1/7-http-security-headers-worth-checking-on-your-saas-59ec</link>
      <guid>https://dev.to/spran1/7-http-security-headers-worth-checking-on-your-saas-59ec</guid>
      <description>&lt;p&gt;Your SaaS already sends HTTP response headers with every response. Some of those headers are instructions the browser follows when it renders your pages, and a few of them close real attack classes. Security testers look for some of them: MDN's &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options" rel="noopener noreferrer"&gt;X-Content-Type-Options page&lt;/a&gt; notes that site security testers usually expect that header to be set.&lt;/p&gt;

&lt;p&gt;One caveat before the list: not every header applies to every response. Several of these matter mostly for HTML documents a browser renders. An API that only returns JSON needs a narrower set. HSTS only has meaning over HTTPS. Check each header against what your app actually serves.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Strict-Transport-Security
&lt;/h2&gt;

&lt;p&gt;HSTS tells browsers your host should only be accessed over HTTPS, and that future HTTP attempts should be upgraded automatically. Once a browser has seen it, it will not let the user bypass certificate errors on your domain either.&lt;/p&gt;

&lt;p&gt;Two details matter. First, browsers ignore the header when it arrives over plain HTTP, so it only counts on your HTTPS responses. Second, &lt;code&gt;includeSubDomains&lt;/code&gt; extends the policy to every subdomain, so only add it when all of them are HTTPS-ready. My advice is to start with a short &lt;code&gt;max-age&lt;/code&gt; and raise it once you are confident nothing on the domain still needs HTTP.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Content-Security-Policy
&lt;/h2&gt;

&lt;p&gt;CSP controls which resources the browser may load for a page: scripts, styles, images, and more. Its main job is limiting the damage of cross-site scripting, because an injected script from an unapproved origin no longer runs.&lt;/p&gt;

&lt;p&gt;This is the hardest header on the list to get right, because a strict policy can break your own frontend. MDN documents &lt;code&gt;Content-Security-Policy-Report-Only&lt;/code&gt; for exactly this reason: you report violations without blocking code while you tune the policy. Use that first, then enforce.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. X-Content-Type-Options: nosniff
&lt;/h2&gt;

&lt;p&gt;This header tells the browser to respect the &lt;code&gt;Content-Type&lt;/code&gt; you sent instead of sniffing the content and guessing. With &lt;code&gt;nosniff&lt;/code&gt;, the browser blocks responses for scripts and styles when the MIME type does not match, and it will not interpret a &lt;code&gt;text/plain&lt;/code&gt; response as HTML.&lt;/p&gt;

&lt;p&gt;That second behavior matters if users can upload files or submit content you later serve back. Sniffing can turn something you meant as plain text into an executed HTML page. Setting &lt;code&gt;nosniff&lt;/code&gt; is one line; it also forces you to keep your &lt;code&gt;Content-Type&lt;/code&gt; headers correct, which you should do anyway.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Referrer-Policy
&lt;/h2&gt;

&lt;p&gt;When a user clicks a link on your site, the browser may send a &lt;code&gt;Referer&lt;/code&gt; header to the destination. Referrer-Policy controls how much of the original URL goes along: full path and query, origin only, or nothing.&lt;/p&gt;

&lt;p&gt;If your URLs ever carry sensitive values, like tokens in a password reset link, the default policy (&lt;code&gt;strict-origin-when-cross-origin&lt;/code&gt;) sends the full URL only on same-origin requests and just the origin on secure cross-origin ones, and that may not be what you want on those pages. You can set a stricter policy such as &lt;code&gt;same-origin&lt;/code&gt; or &lt;code&gt;no-referrer&lt;/code&gt; per response. Match the policy to what your URLs contain.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Permissions-Policy
&lt;/h2&gt;

&lt;p&gt;Permissions-Policy lets you allow or deny browser features like the camera, microphone, and geolocation, for your document and for any iframes inside it.&lt;/p&gt;

&lt;p&gt;If your product never uses these features, denying them is cheap insurance: injected or third-party content on your pages cannot quietly ask for them. The syntax is direct, for example &lt;code&gt;Permissions-Policy: geolocation=(), camera=()&lt;/code&gt;. If only some pages need a feature, send a narrower policy there.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. X-Frame-Options (and frame-ancestors)
&lt;/h2&gt;

&lt;p&gt;Clickjacking works by embedding your page in an invisible frame on another site and tricking the user into clicking. &lt;code&gt;X-Frame-Options: DENY&lt;/code&gt; or &lt;code&gt;SAMEORIGIN&lt;/code&gt; stops other sites from framing your pages.&lt;/p&gt;

&lt;p&gt;The newer replacement is the &lt;code&gt;frame-ancestors&lt;/code&gt; directive inside CSP, which MDN describes as the more comprehensive option and which modern browsers prefer. If you already send a CSP, put &lt;code&gt;frame-ancestors&lt;/code&gt; there; X-Frame-Options still works as a fallback for older browsers.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Cross-Origin-Resource-Policy
&lt;/h2&gt;

&lt;p&gt;CORP tells the browser to block &lt;code&gt;no-cors&lt;/code&gt; cross-origin or cross-site requests for a given resource. The values are &lt;code&gt;same-site&lt;/code&gt;, &lt;code&gt;same-origin&lt;/code&gt;, and &lt;code&gt;cross-origin&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you host resources that other sites should not be embedding, such as private images or downloads reachable by URL, CORP is how you say so. It complements CORS rather than replacing it: CORS governs reading cross-origin responses, which I covered in &lt;a href="https://dev.to/spran1/cors-is-not-a-lock-on-your-api-287i"&gt;yesterday's piece&lt;/a&gt;, while CORP restricts no-cors cross-origin loading of the resource, such as embedding it through an image or script tag.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where these actually get set
&lt;/h2&gt;

&lt;p&gt;You can send these headers from your application framework's middleware, from a reverse proxy like nginx, or from your CDN at the edge. Pick one place per header. Setting the same header in two layers with different values creates confusing behavior that is hard to debug.&lt;/p&gt;

&lt;p&gt;To see what you send today, open your browser's Network panel and inspect the response headers on your own pages, or run a command-line client against them. The &lt;a href="https://owasp.org/www-project-secure-headers/" rel="noopener noreferrer"&gt;OWASP Secure Headers Project&lt;/a&gt; maintains reference material on these headers if you want the deeper version.&lt;/p&gt;

&lt;p&gt;The main takeaway: security headers are response configuration, not a product feature, and most take minutes to check. Verify which ones fit the responses you actually serve, set them in one layer, and confirm them on a live response.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5kl9qofen0vtivyggui.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fn5kl9qofen0vtivyggui.png" alt="How security headers work. The browser sends a request; one layer of the server stack (app, reverse proxy, or CDN) attaches the headers; the response carries Strict-Transport-Security, Content-Security-Policy, X-Content-Type-Options, Referrer-Policy, Permissions-Policy, frame-ancestors or X-Frame-Options, and Cross-Origin-Resource-Policy; the browser then applies them by forcing HTTPS on later visits, blocking framing and MIME sniffing, limiting referrers, and restricting features." width="800" height="550"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/photos/a-row-of-colorful-mail-boxes-sitting-next-to-a-bush-xiqCrk6LvTg" rel="noopener noreferrer"&gt;Philippe Murray-Pietsch&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>backend</category>
    </item>
    <item>
      <title>CORS is not a lock on your API</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Tue, 17 Nov 2026 14:01:01 +0000</pubDate>
      <link>https://dev.to/spran1/cors-is-not-a-lock-on-your-api-287i</link>
      <guid>https://dev.to/spran1/cors-is-not-a-lock-on-your-api-287i</guid>
      <description>&lt;p&gt;Your frontend shows a CORS error. You open the same API endpoint with a command-line client and get a response. That is not a contradiction. The browser and the API server are making different decisions.&lt;/p&gt;

&lt;p&gt;CORS controls which origins a browser lets read cross-origin responses. It does not establish who a caller is or which records that caller may access. Treating it as an API lock leaves the actual access decision in the wrong place.&lt;/p&gt;

&lt;p&gt;There is an important wrinkle: a failed preflight can stop the browser from sending the actual request. So "CORS never blocks requests" is wrong too. The useful question is which request, from which client, and at which stage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with two origins
&lt;/h2&gt;

&lt;p&gt;Imagine a frontend at &lt;code&gt;https://app.example.com&lt;/code&gt; calling &lt;code&gt;https://api.example.com&lt;/code&gt;. They share a parent domain, but their hostnames differ, so they are different origins.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CORS" rel="noopener noreferrer"&gt;MDN CORS guide&lt;/a&gt; describes CORS as an HTTP-header-based mechanism for telling browsers which other origins may load resources. An origin includes the scheme, host, and port. A different port can therefore create the same cross-origin problem during local development.&lt;/p&gt;

&lt;p&gt;The API might return an &lt;code&gt;Access-Control-Allow-Origin&lt;/code&gt; header allowing the frontend's origin. That is permission for the browser's cross-origin access, not evidence that the person using the frontend owns the requested invoice.&lt;/p&gt;

&lt;p&gt;The server still needs to authenticate the caller where required and check permission for that invoice. Do that regardless of whether the request came from the approved frontend, a script, or another server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Some requests go out before the browser refuses the response
&lt;/h2&gt;

&lt;p&gt;MDN calls a category of requests "simple requests," while noting that the term comes from the older CORS specification. These requests do not trigger a preflight.&lt;/p&gt;

&lt;p&gt;For example, a cross-origin GET without non-safelisted request headers may go directly to the API. If the response does not grant the requesting origin access, the browser does not expose it to the calling JavaScript.&lt;/p&gt;

&lt;p&gt;That failure does not mean the API never received the request. It means the script did not get access to the response. If you use the console error as proof that no server-side work happened, you are checking the wrong evidence.&lt;/p&gt;

&lt;p&gt;My advice is to inspect both sides in a test environment: the browser's Network panel and the server's request log. Keep sensitive values out of those logs. A response hidden from JavaScript and a request absent from the server are different outcomes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other requests ask permission first
&lt;/h2&gt;

&lt;p&gt;Now change the call to a POST with &lt;code&gt;Content-Type: application/json&lt;/code&gt;, or add an &lt;code&gt;Authorization&lt;/code&gt; header. Those are examples that trigger CORS preflight rather than meeting the simple-request conditions.&lt;/p&gt;

&lt;p&gt;The browser sends an OPTIONS request describing the intended method and headers. If the preflight fails, it does not proceed with the actual request. If it passes, the browser can proceed, subject to the other applicable browser checks.&lt;/p&gt;

&lt;p&gt;This is why two requests to the same URL can appear to behave differently. One goes directly to the endpoint, while the other stops after OPTIONS. A cached preflight permission can also mean you do not see a fresh OPTIONS request on every call.&lt;/p&gt;

&lt;p&gt;Read the Network panel as a sequence, not a single red error. Was there an OPTIONS request? Was the actual GET or POST sent? Which response failed the browser's access check?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftwda2hklbn7uvbkj0icf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ftwda2hklbn7uvbkj0icf.png" alt="Two browser CORS paths and a non-browser path. A simple cross-origin request goes directly to the server, whose authorization check still applies; the browser checks response-reading permission. A preflighted request sends OPTIONS first and sends the actual request only if allowed. A non-browser client is not subject to browser CORS enforcement but still faces server authorization." width="800" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A non-browser client does not become your frontend
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://github.com/expressjs/cors?tab=readme-ov-file" rel="noopener noreferrer"&gt;Express cors middleware README&lt;/a&gt; makes the boundary explicit: browsers enforce CORS, while clients such as curl, Postman, and other servers do not enforce it.&lt;/p&gt;

&lt;p&gt;An origin allowlist therefore cannot substitute for authentication or object-level authorization. A non-browser client can send requests without obeying browser response-reading rules. It still needs whatever credentials and permissions your server actually requires.&lt;/p&gt;

&lt;p&gt;This does not make CORS pointless. Correctly configured CORS lets your browser frontend use the API while restricting other origins' access to responses. The mistake is asking it to do a separate job: decide who may use the API at all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cookies introduce another question
&lt;/h2&gt;

&lt;p&gt;If your application uses cookies for authentication, do not equate "another origin cannot read this response" with "another site cannot cause an action."&lt;/p&gt;

&lt;p&gt;As MDN explains, simple requests are possible across origins partly because HTML forms have long been able to submit them. Whether cookies accompany a particular request depends on credentials settings, cookie attributes, and browser policy. Cross-origin and cross-site are not interchangeable terms.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html" rel="noopener noreferrer"&gt;OWASP CSRF Prevention Cheat Sheet&lt;/a&gt; recommends using your framework's built-in CSRF protection where available. It treats SameSite cookies as a defense layer, not a universal replacement for CSRF defenses.&lt;/p&gt;

&lt;p&gt;Choose the controls for your authentication design. Do not fix a browser error by allowing arbitrary origins with credentials, and do not assume a strict CORS configuration completes the CSRF work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the boundary you mean to protect
&lt;/h2&gt;

&lt;p&gt;On an API you control, test an allowed browser origin, an unapproved browser origin, and a non-browser client. Check both an unauthenticated request and a request for another test account's record.&lt;/p&gt;

&lt;p&gt;Then separate the results: did the browser send the request, could JavaScript read the response, and did the server authorize the action? Those are different questions. CORS answers the browser-access question. Your API still owns the permission decision.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/photos/brass-colored-padlock-0iFRoNJT4dI" rel="noopener noreferrer"&gt;Guillaume Bourdages&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>security</category>
      <category>backend</category>
    </item>
    <item>
      <title>5 file upload checks your SaaS needs before the first customer</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Mon, 16 Nov 2026 14:00:50 +0000</pubDate>
      <link>https://dev.to/spran1/5-file-upload-checks-your-saas-needs-before-the-first-customer-lm7</link>
      <guid>https://dev.to/spran1/5-file-upload-checks-your-saas-needs-before-the-first-customer-lm7</guid>
      <description>&lt;p&gt;A file upload is an input to your system, not a finished feature when the progress bar reaches 100%. The file may be renamed, parsed, resized, scanned, stored, and downloaded by somebody else. Each step makes a different security decision.&lt;/p&gt;

&lt;p&gt;Before opening uploads to customers, I would check these five boundaries. They are a starting audit, not a promise that an upload pipeline is secure. The details depend on the file types your product actually needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Check the content, not just the label
&lt;/h2&gt;

&lt;p&gt;An upload named &lt;code&gt;invoice.pdf&lt;/code&gt; has made a claim about itself. So has a request carrying &lt;code&gt;Content-Type: application/pdf&lt;/code&gt;. Neither claim is proof.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/File_Upload_Cheat_Sheet.html" rel="noopener noreferrer"&gt;OWASP File Upload Cheat Sheet&lt;/a&gt; recommends allowing only extensions required for the business and warns that the client-supplied Content-Type header can be spoofed. File signatures can help, but OWASP explicitly says not to use them alone.&lt;/p&gt;

&lt;p&gt;Start with the smallest allowlist that supports the feature. If the product needs profile pictures, that does not automatically justify accepting SVG, ZIP, and office documents too. Validate on the server, and use maintained, appropriately configured processing libraries for the formats you accept.&lt;/p&gt;

&lt;p&gt;A useful test: send a file whose extension, MIME header, and actual content disagree. Record which layer rejects it. A browser file-picker restriction is a convenience, not that layer.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Separate the display name from the storage key
&lt;/h2&gt;

&lt;p&gt;A customer can call a document &lt;code&gt;quarterly-report.pdf&lt;/code&gt;. That does not mean the same string should become its path on disk or its object-storage key.&lt;/p&gt;

&lt;p&gt;OWASP recommends generating filenames in the application, with UUIDs as one example. Keep the original name as separately validated display metadata if the product needs it. Put length and character limits on that metadata too.&lt;/p&gt;

&lt;p&gt;My suggested design is a database record linking an application-generated key to the owner, the display name, and the processing state. Do not accept an arbitrary path from the request and treat it as a storage destination.&lt;/p&gt;

&lt;p&gt;Test duplicate names and path-like names. Two customers uploading &lt;code&gt;logo.png&lt;/code&gt; should not accidentally share a storage identity. A generated key helps separate the names; it does not replace an ownership check when somebody asks to read the file.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Limit the work the upload can create
&lt;/h2&gt;

&lt;p&gt;A byte limit at the HTTP boundary answers one question: how large is the incoming request? It does not answer how much work a parser, image decoder, or archive extractor will do afterward.&lt;/p&gt;

&lt;p&gt;OWASP identifies huge files and ZIP or XML bombs as upload threats. For workflows that extract files, it calls for considering size limits after decompression as well.&lt;/p&gt;

&lt;p&gt;Choose limits for the operations your feature performs: accepted upload size, expanded archive size if archives are supported, and processing time or resource use. These are design limits to test, not universal numbers to copy from an example.&lt;/p&gt;

&lt;p&gt;Reject formats you do not need. If archives are unnecessary, refusing them is simpler than building an extraction service. Also test the failure path: an oversized input should not leave unbounded temporary files or a job that retries forever.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fns25xbx80dbocg8m8myo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fns25xbx80dbocg8m8myo.png" alt="Proposed upload pipeline: check upload permission, store a pending file privately, validate type and resource limits and scan as appropriate, then mark approved. Rejected or failed checks stay unavailable. Each download separately checks permission before serving an approved file." width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Keep pending files away from the download path
&lt;/h2&gt;

&lt;p&gt;Receiving bytes and approving them for use are separate events. A file should not become customer-accessible just because storage accepted it.&lt;/p&gt;

&lt;p&gt;OWASP prefers a separate storage host or, where that is not possible, storage outside the webroot. It also recommends antivirus or sandbox checks where available, and content disarm and reconstruction for applicable formats. These are layers, not certificates of harmlessness.&lt;/p&gt;

&lt;p&gt;For an asynchronous pipeline, my advice is an explicit state model: &lt;code&gt;pending&lt;/code&gt;, &lt;code&gt;approved&lt;/code&gt;, or &lt;code&gt;rejected&lt;/code&gt;. Only approved files enter the serving path. If a required check times out or its worker fails, leave the file unavailable rather than silently treating the error as approval.&lt;/p&gt;

&lt;p&gt;Keep parsing and scanning permissions narrow. A scanner does not need the same access as the application administrator. Check the storage policy as well as the application route: a private download controller cannot protect a file that also has an unrestricted public URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Authorize the download, not just the upload
&lt;/h2&gt;

&lt;p&gt;Logging in proves which account made a request. It does not prove that account may read a particular document.&lt;/p&gt;

&lt;p&gt;OWASP's &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Cheat_Sheet.html" rel="noopener noreferrer"&gt;Authorization Cheat Sheet&lt;/a&gt; recommends denying access by default and validating permissions on every request. Apply that to file retrieval, replacement, and deletion, not only to the form that creates the file.&lt;/p&gt;

&lt;p&gt;Test with two accounts. Upload a private document with account A, then request its identifier as account B. Repeat for any thumbnail or converted preview. The derivative should not become an accidental way around the original document's access rules.&lt;/p&gt;

&lt;p&gt;For deliberately public uploads, make that policy explicit. Public visibility is a product decision, not a side effect of choosing a convenient storage bucket.&lt;/p&gt;

&lt;h2&gt;
  
  
  Before you ship
&lt;/h2&gt;

&lt;p&gt;Walk one file through the whole path. Check its type, give it an application-owned storage key, bound the work it creates, keep it private until required checks pass, and authorize access when it is served. Then test rejection and worker failure, not only the successful upload.&lt;/p&gt;

&lt;p&gt;Those five checks do not finish security. They give you concrete boundaries to inspect before customer files depend on them.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/photos/gray-metal-drawers-h6xNSDlgciU" rel="noopener noreferrer"&gt;jesse orrico&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>webdev</category>
      <category>backend</category>
    </item>
    <item>
      <title>Your health check endpoint can take your app down</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Sun, 15 Nov 2026 14:01:14 +0000</pubDate>
      <link>https://dev.to/spran1/your-health-check-endpoint-can-take-your-app-down-2p6d</link>
      <guid>https://dev.to/spran1/your-health-check-endpoint-can-take-your-app-down-2p6d</guid>
      <description>&lt;p&gt;Who calls your &lt;code&gt;/health&lt;/code&gt; endpoint, what does it check, and what happens when it fails? Those three answers decide whether a slow dependency stays a slow dependency or becomes an outage.&lt;/p&gt;

&lt;p&gt;The endpoint itself is simple. The systems consuming it are not, and they do different things with a failure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three consumers, three different reactions
&lt;/h2&gt;

&lt;p&gt;A health check is not one mechanism. It is at least three, and mixing them up is where the trouble starts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Kubernetes liveness probe decides when to restart a container.&lt;/strong&gt; The &lt;a href="https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle/" rel="noopener noreferrer"&gt;Kubernetes documentation&lt;/a&gt; says that if a container fails its liveness probe more times than the configured tolerance, the kubelet restarts that container. Restart is the remedy for a process that is stuck, for example in a deadlock.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A Kubernetes readiness probe decides whether a pod gets traffic.&lt;/strong&gt; If the readiness probe fails, the EndpointSlice controller removes the pod's IP address from the EndpointSlices of all matching Services. The container is not restarted. It keeps running; it just stops receiving requests until the probe passes again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An AWS Application Load Balancer health check decides whether a target stays in rotation.&lt;/strong&gt; Per the &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html" rel="noopener noreferrer"&gt;ELB documentation&lt;/a&gt;, after UnhealthyThresholdCount consecutive failures the load balancer takes the target out of service. It does not restart or replace anything. And there is a caveat worth knowing before you rely on it: if every registered target in all enabled Availability Zones fails health checks at the same time, the load balancer fails open and routes requests to all of them, regardless of health status.&lt;/p&gt;

&lt;p&gt;Restarts, removal from endpoints, removal from rotation, and fail-open are four different responses to the same failed HTTP call.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxl7npxjroj7orcsp1n4v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxl7npxjroj7orcsp1n4v.png" alt="Comparison of three health-check consumers: a Kubernetes liveness probe restarts the container on repeated failure, a Kubernetes readiness probe removes the pod from Service endpoints without a restart, and an AWS ALB health check removes the target from rotation, with a fail-open caveat when all targets fail at once" width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the cascade starts
&lt;/h2&gt;

&lt;p&gt;Now make the endpoint deep: before returning 200, it runs a test query against the database and pings a third-party API. The intent is good. The blast radius is not.&lt;/p&gt;

&lt;p&gt;The database gets slow for reasons unrelated to your app code. Every instance's deep check starts failing at the same time, because every instance shares that database. What happens next depends on which consumer is wired to that endpoint:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Wired to a liveness probe: the kubelet restarts healthy application containers across the fleet because a dependency is slow. Restarts add load and cold starts to an already degraded system.&lt;/li&gt;
&lt;li&gt;Wired to a readiness probe or an ALB: every instance leaves rotation at once. With an ALB, once all targets report unhealthy in all enabled zones, the fail-open behavior sends traffic back to all of them, including instances that still cannot reach the database.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Either way, one slow shared dependency has been amplified into an app-wide event. The check did not detect the outage. It created the shape of it.&lt;/p&gt;

&lt;p&gt;These reactions are also slower than they look. The same ELB documentation notes that an ALB checks each target about every HealthCheckIntervalSeconds, 30 seconds by default for instance and IP targets, and only removes it after consecutive failures. A failing instance can keep serving errors for minutes before rotation changes. Kubernetes probes have their own configurable failure tolerances.&lt;/p&gt;

&lt;h2&gt;
  
  
  The opposite failure
&lt;/h2&gt;

&lt;p&gt;The shallow version has its own cost. An endpoint that returns 200 as long as the process runs will keep an instance in rotation while the app cannot serve real requests: deadlocked workers, a broken configuration load, a missing environment variable. Users get errors from instances every check calls healthy.&lt;/p&gt;

&lt;p&gt;So deep is dangerous and shallow is blind. That tension is the actual design problem.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I would wire it
&lt;/h2&gt;

&lt;p&gt;My advice, and it is advice rather than a rule: keep the endpoint that load balancers and probes consume shallow. It should answer "is this process up and able to accept work," not "is every dependency healthy." Put dependency checks on a separate route that monitoring and humans read, where a failure pages someone instead of changing traffic.&lt;/p&gt;

&lt;p&gt;If a dependency check must influence traffic, scope it to what the instance can actually do about it. An instance cannot fix a slow database by leaving rotation, and a fleet of instances leaving rotation together is worse than the original slowness.&lt;/p&gt;

&lt;p&gt;Then test the behavior rather than assuming it: in a controlled environment, make a dependency slow and watch which probes fail, what the orchestrator and load balancer do, and whether the fail-open path behaves the way the documentation describes.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;p&gt;A health check is a control loop, not a formality. Kubernetes liveness restarts, readiness removes from endpoints, and an ALB removes from rotation with a fail-open caveat when everything fails together. Point them at an endpoint that checks shared dependencies, and one slow dependency can take down healthy code. Keep the traffic-path check shallow, move deep checks to monitoring, and verify the real behavior in a test you control.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/photos/a-large-monitor-displaying-a-number-of-times-0V7aC2SEm5U" rel="noopener noreferrer"&gt;Samuel Ramos&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>webdev</category>
      <category>backend</category>
    </item>
    <item>
      <title>7 things that break when your launch day traffic actually shows up</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Sat, 14 Nov 2026 14:00:56 +0000</pubDate>
      <link>https://dev.to/spran1/7-things-that-break-when-your-launch-day-traffic-actually-shows-up-52ca</link>
      <guid>https://dev.to/spran1/7-things-that-break-when-your-launch-day-traffic-actually-shows-up-52ca</guid>
      <description>&lt;p&gt;A launch-day spike is a strange kind of success. The same attention you wanted becomes a stress test you did not schedule.&lt;/p&gt;

&lt;p&gt;A small SaaS stack runs on fixed limits that are easy to miss until traffic arrives: connection caps, rate limits, sending quotas, defaults that shipped with the platform. Here are seven failure modes worth checking before the traffic arrives.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Your database runs out of connections
&lt;/h2&gt;

&lt;p&gt;PostgreSQL allows at most &lt;code&gt;max_connections&lt;/code&gt; simultaneous connections, and the &lt;a href="https://www.postgresql.org/docs/current/runtime-config-connection.html" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt; notes that near the limit, remaining slots are reserved for superusers as an emergency reserve. Every app server, worker, and background job holds connections open. A spike multiplies all of them at once.&lt;/p&gt;

&lt;p&gt;Check your pool sizes now: add up the maximum pool of every process that talks to the database and compare the total to &lt;code&gt;max_connections&lt;/code&gt;. If the sum can exceed the limit, put a connection pooler in front or lower the pools.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. A slow dependency stalls everything
&lt;/h2&gt;

&lt;p&gt;When one dependency gets slow under load, requests pile up behind it. Without timeouts, each waiting request still holds a worker, a connection, and memory. That is how localized slowness can spread until your whole app looks down.&lt;/p&gt;

&lt;p&gt;One concrete example from your own stack: if you sit behind an AWS Application Load Balancer, &lt;a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/application/edit-load-balancer-attributes.html" rel="noopener noreferrer"&gt;its idle timeout defaults to 60 seconds&lt;/a&gt;, and AWS recommends setting your application's idle timeout larger than the load balancer's. Otherwise the load balancer can send a request down a connection the application has already begun to close. Check the equivalent defaults wherever you run, and my advice is to set explicit timeouts on every outbound call while you are there.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Third-party APIs start returning 429
&lt;/h2&gt;

&lt;p&gt;Your checkout, your email sender, your maps provider: each one rate-limits you, and your spike is their Tuesday. &lt;a href="https://docs.stripe.com/rate-limits" rel="noopener noreferrer"&gt;Stripe's rate-limit documentation&lt;/a&gt; is a good example of what to expect: limits are measured in requests per second, per account and per endpoint, and exceeding them returns &lt;code&gt;429 Too Many Requests&lt;/code&gt; responses.&lt;/p&gt;

&lt;p&gt;Before launch, find the published limits for every paid API in your critical path and decide what your app does at 429. Retrying immediately makes it worse. Queue the work, back off, and surface an honest message instead of a broken page.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Your email provider throttles the welcome flood
&lt;/h2&gt;

&lt;p&gt;A signup spike means a welcome-email spike. &lt;a href="https://docs.aws.amazon.com/ses/latest/dg/manage-sending-quotas.html" rel="noopener noreferrer"&gt;Amazon SES enforces two sending quotas&lt;/a&gt;: a maximum number of messages per rolling 24-hour period and a maximum send rate per second. A send that would exceed the daily maximum is not accepted. Separate from those caps, SES says quotas exist to help you ramp up gradually, because sudden, unexpected spikes make email providers more likely to block your mail.&lt;/p&gt;

&lt;p&gt;Check your current daily and per-second quotas against your expected launch volume. If the caps are lower, request an increase ahead of time, because approval is not instant.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Webhooks arrive in a burst, and retries keep coming
&lt;/h2&gt;

&lt;p&gt;Payment events, subscription events, and form submissions all surge together. If your endpoint falls behind or returns errors, the sender does not stop: &lt;a href="https://docs.stripe.com/webhooks/signature" rel="noopener noreferrer"&gt;Stripe's webhook documentation&lt;/a&gt; says that in live mode it attempts redelivery with exponential backoff for up to three days, while events created in a sandbox are retried three times over a few hours. That is recovery help, but it also means a struggling endpoint gets retried traffic on top of new traffic.&lt;/p&gt;

&lt;p&gt;Make the endpoint fast and boring: verify the signature, store the event, return a 200, and do the real work asynchronously. Guard against processing the same event twice, because retries and recovery scripts can overlap.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Queues grow quietly until they are the outage
&lt;/h2&gt;

&lt;p&gt;Queues absorb spikes by design. &lt;a href="https://www.rabbitmq.com/docs/queues" rel="noopener noreferrer"&gt;RabbitMQ describes queues as a data accumulation buffer for consumers&lt;/a&gt;. That buffer is exactly what saves you, and exactly what hides the problem: if consumers cannot keep up, the queue just grows.&lt;/p&gt;

&lt;p&gt;A growing queue is not a processed spike; it is a delayed one. Watch queue depth and consumer lag, not just request rate. Decide in advance which jobs can wait an hour and which cannot.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. The humans become the bottleneck
&lt;/h2&gt;

&lt;p&gt;Every item above can land in your support inbox within the same hour. Password resets, failed payments, "is it down" messages. No auto-scaler answers those.&lt;/p&gt;

&lt;p&gt;Write the status-page template and the three most likely reply templates before launch. Decide who watches what, and for how long. Templates and named owners cost little compared to the rest of this list.&lt;/p&gt;

&lt;h2&gt;
  
  
  The short version
&lt;/h2&gt;

&lt;p&gt;Read the limits before your users find them: database connections, timeouts, API rate limits, email quotas, webhook retries, queue depth, and your own reply time. Start with an audit: read each provider's current limits, compare them against your expected volume, and then decide what actually needs to change. Some fixes will be a config line; others will need more.&lt;/p&gt;

&lt;p&gt;If you are still deciding where to list the launch itself, I run a free launch board at &lt;a href="https://startupwiki.tech/launch" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt; with badge verification and no listing expiry. Wherever you list it, the checklist above stays the same.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2uqg3yjvffuke15nkim9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2uqg3yjvffuke15nkim9.png" alt="A request's path during a traffic spike: load balancer, app workers, database connection pool, third-party APIs, email provider, webhook endpoint, and queue, each marked with the limit that can break there." width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/photos/a-close-up-of-a-server-in-a-server-room-vSprjjDbu60" rel="noopener noreferrer"&gt;Tyler&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>performance</category>
      <category>backend</category>
    </item>
    <item>
      <title>Your timeout isn't a stop button</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Fri, 13 Nov 2026 14:00:42 +0000</pubDate>
      <link>https://dev.to/spran1/your-timeout-isnt-a-stop-button-2a0l</link>
      <guid>https://dev.to/spran1/your-timeout-isnt-a-stop-button-2a0l</guid>
      <description>&lt;p&gt;A timeout says when an operation is no longer wanted. It does not prove that every piece of work behind that operation has stopped.&lt;/p&gt;

&lt;p&gt;In Go, &lt;code&gt;context.Context&lt;/code&gt; carries deadlines and cancellation signals. Your code has to pass that context to the work it starts, and the receiving code has to support cancellation. A timer around the outer request cannot repair a broken chain inside it.&lt;/p&gt;

&lt;p&gt;That distinction matters when a slow database query outlives the request that started it. Here is how I would review that chain, using Go's documented behavior rather than assuming a timeout is a kill switch.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with the request, not a fresh background
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://go.dev/doc/database/cancel-operations" rel="noopener noreferrer"&gt;Go's database cancellation guide&lt;/a&gt; shows a context derived from its caller, with a timeout added for a database operation. That parent-child relationship is the important part.&lt;/p&gt;

&lt;p&gt;For work needed by an HTTP request, start with &lt;code&gt;r.Context()&lt;/code&gt;. Derive a child context if that operation needs a tighter limit. If you start from &lt;code&gt;context.Background()&lt;/code&gt; instead, you create a separate root. Canceling the request's context will not cancel that unrelated context.&lt;/p&gt;

&lt;p&gt;A background context is not inherently wrong. It is wrong when you intend work to follow the request's lifetime but accidentally disconnect it. A durable job that must survive the request needs its own explicit lifetime and ownership. It should not survive merely because somebody forgot to pass an argument.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pass the deadline to the operation
&lt;/h2&gt;

&lt;p&gt;This function is an illustrative pattern, not a benchmark or a complete endpoint. It assumes an existing &lt;code&gt;*sql.DB&lt;/code&gt; and an &lt;code&gt;album&lt;/code&gt; table. It needs the standard &lt;code&gt;context&lt;/code&gt;, &lt;code&gt;database/sql&lt;/code&gt; and &lt;code&gt;time&lt;/code&gt; packages.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="nf"&gt;albumTitles&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;sql&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="no"&gt;DB&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;queryCtx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;cancel&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;WithTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ctx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Second&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="nf"&gt;cancel&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;QueryContext&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;queryCtx&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"SELECT title FROM album"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;defer&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Close&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;titles&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="n"&gt;titles&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;titles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;rows&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;titles&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;nil&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An HTTP handler would pass &lt;code&gt;r.Context()&lt;/code&gt; as the first argument. The two-second value is an example, not a recommended production setting. Choose a budget that fits the endpoint and its dependencies.&lt;/p&gt;

&lt;p&gt;Notice what the function does not do: create a context and then call &lt;code&gt;db.Query&lt;/code&gt; without it. The timeout must reach the operation through &lt;code&gt;QueryContext&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Also keep the context alive while consuming the rows. Returning rows from a helper that immediately runs a deferred &lt;code&gt;cancel()&lt;/code&gt; would give the caller a result stream whose context has already been canceled. Here, scanning happens before the helper returns.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://pkg.go.dev/database/sql" rel="noopener noreferrer"&gt;&lt;code&gt;database/sql&lt;/code&gt; documentation&lt;/a&gt; specifies checking &lt;code&gt;rows.Err()&lt;/code&gt; after iteration. A loop ending is not enough evidence that all rows were read successfully.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feh3awa5wz34luvzjuw2t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Feh3awa5wz34luvzjuw2t.png" alt="Go cancellation chain: an HTTP request context leads to a derived query context and QueryContext, then a driver that must support cancellation. A separate Background context has no cancellation link to the request." width="800" height="486"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A child timeout cannot extend its parent
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://pkg.go.dev/context" rel="noopener noreferrer"&gt;&lt;code&gt;context&lt;/code&gt; documentation&lt;/a&gt; defines a derived deadline as no later than the parent's deadline. Giving a database call two seconds does not grant it two fresh seconds if the caller has less time remaining.&lt;/p&gt;

&lt;p&gt;Think of that local timeout as an upper bound. The child can end because its own deadline expires, its parent is canceled, or its cancellation function is called. You cannot make the original request live longer by repeatedly wrapping it in new child contexts.&lt;/p&gt;

&lt;p&gt;Keep &lt;code&gt;defer cancel()&lt;/code&gt; even when the operation normally finishes before its deadline. Go's guide explains that calling it releases resources associated with the derived context. Waiting for the timer is unnecessary.&lt;/p&gt;

&lt;h2&gt;
  
  
  The driver is part of the contract
&lt;/h2&gt;

&lt;p&gt;There is a limit to what the wrapper above promises. The &lt;code&gt;database/sql&lt;/code&gt; documentation explicitly says drivers without context-cancellation support will not return until the query completes.&lt;/p&gt;

&lt;p&gt;That means a correctly passed context is necessary, but it is not evidence that your particular database stack stopped promptly. Verify the driver and the behavior you depend on. Do not write an operational guarantee based only on the method name.&lt;/p&gt;

&lt;p&gt;The same distinction applies to your own long-running work. The context's &lt;code&gt;Done()&lt;/code&gt; channel tells code when cancellation is requested. It does not insert a cancellation check into an arbitrary loop. And calling a &lt;code&gt;CancelFunc&lt;/code&gt; does not wait for the work to stop, as the context documentation makes clear.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the end of the chain
&lt;/h2&gt;

&lt;p&gt;My review would use a controlled, non-production slow operation. Cancel its parent before the operation finishes. Separately, let the child deadline expire. Observe when the function returns and, using the database's own tooling, whether the underlying query actually ends.&lt;/p&gt;

&lt;p&gt;Those are different observations. A handler returning an error is not by itself proof that no downstream work remains. Record cancellation and deadline expiry distinctly when that helps diagnosis, without exposing credentials or customer data.&lt;/p&gt;

&lt;p&gt;The useful question is not "Did I set a timeout?" It is "Did cancellation reach the work, and did that work respond?" Follow that chain through the API, the result-reading code and the driver before treating the timeout as protection.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/photos/laptop-displaying-code-on-a-desk-dTmj5aXbKp4" rel="noopener noreferrer"&gt;Dawit&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>go</category>
      <category>backend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>5 things to keep out of your application logs</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Thu, 12 Nov 2026 14:01:04 +0000</pubDate>
      <link>https://dev.to/spran1/5-things-to-keep-out-of-your-application-logs-1d1d</link>
      <guid>https://dev.to/spran1/5-things-to-keep-out-of-your-application-logs-1d1d</guid>
      <description>&lt;p&gt;A useful log explains what happened without becoming a second store of credentials and customer data. That distinction gets lost when a convenient debug statement turns an entire request into a permanent record.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Logging_Cheat_Sheet.html" rel="noopener noreferrer"&gt;OWASP's Logging Cheat Sheet&lt;/a&gt; identifies data that should usually not be recorded directly, including passwords, access tokens, session identifiers, database connection strings and sensitive personal information. It also recommends recording useful security events. The answer is not to switch logging off.&lt;/p&gt;

&lt;p&gt;These five checks are a starting point for reviewing what your application emits. They are not a complete compliance checklist or a promise that a redaction library catches everything.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Passwords and other primary secrets
&lt;/h2&gt;

&lt;p&gt;A failed login is worth recording. The password that failed is not.&lt;/p&gt;

&lt;p&gt;Keep the event type, time, outcome and an appropriate account or interaction identifier. Do not serialize the submitted login form just because authentication threw an exception. The same review should cover password-reset inputs, encryption keys and other primary secrets.&lt;/p&gt;

&lt;p&gt;My suggestion is to define the event before choosing its fields. A &lt;code&gt;login_failed&lt;/code&gt; event with a reason category is easier to review than a generic error containing whatever object happened to be available.&lt;/p&gt;

&lt;p&gt;Also inspect the error path. Removing a password from the normal request logger does not help if an exception handler later dumps the original request. OWASP's &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html" rel="noopener noreferrer"&gt;Secrets Management Cheat Sheet&lt;/a&gt; treats secret handling as a lifecycle problem, not something solved by hiding one field in one place.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Access tokens and raw session identifiers
&lt;/h2&gt;

&lt;p&gt;An authorization failure can be useful evidence without including the credential used in the attempt. Review authorization headers, cookies and token-bearing URLs rather than looking only for a JSON field named &lt;code&gt;token&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;OWASP lists access tokens and session identification values among data that usually should not be recorded directly. If session-level correlation is necessary, its logging guidance suggests considering a hashed replacement for the session value.&lt;/p&gt;

&lt;p&gt;That is not an instruction to hash every secret and keep the result forever. Decide why correlation is needed, how the replacement is generated and who can access it. A stable identifier can still connect activity across records.&lt;/p&gt;

&lt;p&gt;For routine debugging, consider an interaction ID created for the request. Use it to connect the safe events in that request rather than copying the user's bearer token into each line. The identifier itself still needs a clear format and purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Database connection strings and service credentials
&lt;/h2&gt;

&lt;p&gt;A connection error does not need to print the credential that failed. Connection strings can combine routing details with authentication material, so treating the whole string as harmless configuration is a poor default.&lt;/p&gt;

&lt;p&gt;Record the operation, a safe service alias, a classified error and the interaction ID where useful. Keep the actual credential out of the message. Decide separately whether internal hostnames or paths belong in the logging system; OWASP notes that these can also need special treatment.&lt;/p&gt;

&lt;p&gt;Do not rely on replacing the password in one familiar URL pattern. A driver, SDK or configuration library may format errors differently. Test the libraries your application uses, including startup failures before your ordinary request middleware is running.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5hjb3ya3bn8x8f3r5eog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5hjb3ya3bn8x8f3r5eog.png" alt="Illustrative logging boundary: application events become a defined safe field set, then pass output checks before reaching log storage. Raw requests and secrets are excluded rather than copied wholesale." width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Sensitive personal and financial data
&lt;/h2&gt;

&lt;p&gt;A support case might need an internal customer reference. It does not automatically need the customer's health details, government identifier or payment-card data copied into an application log.&lt;/p&gt;

&lt;p&gt;OWASP recommends excluding or protecting sensitive personal information and financial data. It also says ordinary personal information, such as names and email addresses, may need special handling. This is not a universal claim that no personal data can ever be logged. Purpose, consent, applicable rules and the logging system's permitted data classification matter.&lt;/p&gt;

&lt;p&gt;For each field, ask what investigation it enables and whether a less revealing reference would work. Then define access and retention for the resulting records. Calling a field "debug data" does not settle those decisions.&lt;/p&gt;

&lt;p&gt;Use synthetic customer values when testing this boundary. There is no reason to paste a real customer's private record into a test log to find out whether your filter works.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Whole request and response bodies
&lt;/h2&gt;

&lt;p&gt;This is the collection mechanism that can undo the other four checks. A blanket body dump can pick up new fields when your API changes, even if nobody edits the logger.&lt;/p&gt;

&lt;p&gt;Full payload logging is not necessary for every useful event. My default would be a small, explicit set of fields for each event, with a separate, reviewed process when deeper diagnostics are genuinely required. An allowlist still needs maintenance: a permitted field can become sensitive when its meaning changes.&lt;/p&gt;

&lt;p&gt;Redaction is another layer, not proof of safety. Test nested objects, arrays, error messages and unexpected field names. Check the emitted record at the destination, not only the object passed to your logging function.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the event, review the data
&lt;/h2&gt;

&lt;p&gt;Start with one important workflow. Trigger success, validation failure and an exception using clearly synthetic markers. Inspect what reaches each configured destination. Confirm that useful outcomes remain visible and restricted values do not appear.&lt;/p&gt;

&lt;p&gt;Then add that check to your release process. Logging changes when code, SDKs and configuration change. The goal is a record you can investigate without first wondering whether the record itself contains another secret to protect.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/photos/laptop-with-code-plant-and-coffee-cup-on-desk-K6Y3xEjRuh0" rel="noopener noreferrer"&gt;Daniil Komov&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>security</category>
      <category>backend</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Your webhook can arrive twice. Your code should act once.</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Wed, 11 Nov 2026 14:01:07 +0000</pubDate>
      <link>https://dev.to/spran1/your-webhook-can-arrive-twice-your-code-should-act-once-lh8</link>
      <guid>https://dev.to/spran1/your-webhook-can-arrive-twice-your-code-should-act-once-lh8</guid>
      <description>&lt;p&gt;A webhook is a notification, not a promise that your handler will run once. If your application treats every delivery as new work, a retry can repeat an email, an entitlement change, or a provisioning job.&lt;/p&gt;

&lt;p&gt;Stripe explicitly documents that webhook endpoints can receive the same event more than once. That does not mean Stripe charges a customer again whenever it repeats a notification. Receiving an event and initiating a payment are different operations. This article is about what your application does after receiving the notification.&lt;/p&gt;

&lt;p&gt;The useful design question is simple: if this work runs again, what happens?&lt;/p&gt;

&lt;h2&gt;
  
  
  A receipt is not a completed job
&lt;/h2&gt;

&lt;p&gt;Consider an illustrative SaaS application. A verified billing event arrives, and the application needs to update a local entitlement record. The handler checks whether it has seen the event, changes the entitlement, records completion, and responds.&lt;/p&gt;

&lt;p&gt;That sounds reasonable until the process stops between two of those steps.&lt;/p&gt;

&lt;p&gt;If it changes the entitlement and crashes before recording completion, a later attempt may repeat the change. If it records completion first and crashes before changing the entitlement, a later attempt may skip work that never happened.&lt;/p&gt;

&lt;p&gt;The problem is the gap between the effect and the record of that effect. Changing the order does not remove the gap.&lt;/p&gt;

&lt;p&gt;For a local database change, I would start by putting the relevant state change and its completion record in the same database transaction. PostgreSQL's &lt;a href="https://www.postgresql.org/docs/current/tutorial-transactions.html" rel="noopener noreferrer"&gt;transaction tutorial&lt;/a&gt; describes the all-or-nothing boundary: the transaction's updates become a unit. This only helps with work inside that transaction. It does not turn an unrelated email API into part of your database commit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give delivery and processing separate jobs
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.stripe.com/webhooks" rel="noopener noreferrer"&gt;Stripe's webhook guidance&lt;/a&gt; recommends checking signatures, returning a successful response quickly, and handling events asynchronously. Signature verification needs the raw request body, so do not let middleware transform it before verification.&lt;/p&gt;

&lt;p&gt;One design worth evaluating is a durable inbox. The receiving endpoint verifies the event and stores a receipt that a worker can process later. It acknowledges the notification after durable acceptance, rather than waiting for a slow business workflow.&lt;/p&gt;

&lt;p&gt;That is a suggested architecture, not a guarantee supplied by Stripe. You still need a working path from the inbox to a worker. If a queue is used, account for a crash after storing the receipt but before publishing the queue message. A durable row that nobody revisits is not a completed handoff.&lt;/p&gt;

&lt;p&gt;For a small system, a worker that claims pending inbox rows may be easier to reason about than coordinating two separate writes. Choose the mechanism your team can operate and recover.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F709jutbjyq92y5qnsx5m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F709jutbjyq92y5qnsx5m.png" alt="Illustrative durable-inbox flow: verify and persist a uniquely keyed receipt, acknowledge durable acceptance, let a worker apply a local change and completion together, and retry unfinished work. External effects need their own retry-safe boundary." width="800" height="507"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  A check before an insert is not enough
&lt;/h2&gt;

&lt;p&gt;Two requests can arrive close together. Both can ask whether an event exists before either has inserted it. An application-level check alone leaves that race open.&lt;/p&gt;

&lt;p&gt;Use the database's constraint mechanism for the receipt identity. PostgreSQL's &lt;a href="https://www.postgresql.org/docs/current/ddl-constraints.html" rel="noopener noreferrer"&gt;unique-constraint documentation&lt;/a&gt; explains uniqueness across a column or group of columns. Make the identifying fields non-null, and choose a key scoped to the provider and account context your application actually handles.&lt;/p&gt;

&lt;p&gt;A duplicate receipt should not create a second inbox job. But the original job may still be pending or failed. Deduplicating delivery is not permission to forget unfinished processing.&lt;/p&gt;

&lt;p&gt;Worker concurrency is another boundary. Decide how a worker claims a row, how another worker knows it is claimed, and how abandoned claims become eligible again. Those details depend on your database and queue. A boolean called &lt;code&gt;processed&lt;/code&gt; is not a recovery design by itself.&lt;/p&gt;

&lt;h2&gt;
  
  
  The event ID is only one kind of identity
&lt;/h2&gt;

&lt;p&gt;Stripe recommends tracking processed event IDs to identify duplicate deliveries. It also notes that separate Event objects can sometimes describe duplicates; its guidance points to the object ID and event type for identifying those cases.&lt;/p&gt;

&lt;p&gt;Do not turn that into a universal rule that every event concerning the same object is redundant. Different events can represent legitimate state changes. Define what one business operation means before choosing its deduplication key.&lt;/p&gt;

&lt;p&gt;For the entitlement example, distinguish setting a record to a known state from appending another grant. They have different repeat behavior. Also, Stripe does not guarantee event delivery order. An older notification must not blindly overwrite a newer state just because it arrived later. Where needed, use the provider's current object state and your application's transition rules rather than assuming arrival order is chronology.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the uncomfortable interruption
&lt;/h2&gt;

&lt;p&gt;Before calling the handler ready, deliberately test duplicate delivery, two concurrent workers, and a crash around the commit boundary. Include a failed job that is retried after the receiving endpoint has already acknowledged it.&lt;/p&gt;

&lt;p&gt;If the effect is external, such as sending an email, test that boundary separately. Check whether the destination supports an idempotency key, what it covers, and how long it lasts. Without a shared transaction or a suitable destination guarantee, recording a successful send and making the send remain separate actions. Do not label that exactly-once processing.&lt;/p&gt;

&lt;p&gt;The goal is not to make retries disappear. It is to make repeated delivery and interrupted work ordinary cases your system can explain and recover from. Keep a durable receipt, keep unfinished work visible, and make each effect safe to retry within its actual boundary.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/photos/a-yellow-ethernet-cable-on-a-blue-background-uBcgQA7fwEA" rel="noopener noreferrer"&gt;Markus Spiske&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>backend</category>
      <category>saas</category>
    </item>
    <item>
      <title>5 ways to cut your AI API bill</title>
      <dc:creator>spran wiki</dc:creator>
      <pubDate>Tue, 10 Nov 2026 14:00:49 +0000</pubDate>
      <link>https://dev.to/spran1/5-ways-to-cut-your-ai-api-bill-50g7</link>
      <guid>https://dev.to/spran1/5-ways-to-cut-your-ai-api-bill-50g7</guid>
      <description>&lt;p&gt;An AI feature can answer correctly and still cost too much to run. Before swapping models, look at what you are asking the API to do: how many calls, how much input, how much output, and how often the same work repeats.&lt;/p&gt;

&lt;p&gt;These five changes are worth testing. They are not a promise of a particular saving. The useful number is cost per successful task, with your quality requirements held steady. A cheaper answer that needs a second attempt might not be cheaper work.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Remove calls that do not need a model
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://developers.openai.com/api/docs/guides/cost-optimization" rel="noopener noreferrer"&gt;OpenAI's cost-optimization guide&lt;/a&gt; starts with reducing requests, minimizing tokens, and choosing an appropriately sized model. Start with the request count because it is easy to overlook while comparing token prices.&lt;/p&gt;

&lt;p&gt;As a design exercise, trace one user action through your application. Does it trigger a separate call to classify the request, another to rewrite it, and another to answer it? Each call may be justified. The point is to check, not to combine everything blindly.&lt;/p&gt;

&lt;p&gt;A fixed lookup or an ordinary validation rule might not need a model. That is an engineering judgment, not a claim that every classification task belongs in an if statement. Test the simpler path against the cases your feature actually handles.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Send less irrelevant input
&lt;/h2&gt;

&lt;p&gt;A model cannot usefully answer from information you removed if that information was necessary. So the target is irrelevant input, not the shortest possible prompt.&lt;/p&gt;

&lt;p&gt;For a support feature, consider whether each request needs the entire product manual or only the sections relevant to the question. For document extraction, decide which pages belong to the task before sending an archive of unrelated material.&lt;/p&gt;

&lt;p&gt;Those are illustrative designs. Their quality depends on how reliably you select the right context. Keep a test case where the answer depends on a detail near the end of a document. A trimming strategy that loses that detail has failed even if the invoice falls.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Famntyufh3kwx0wjuzag7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Famntyufh3kwx0wjuzag7.png" alt="Illustrative optimization loop: measure a baseline, change one request or token lever, evaluate quality and cost per successful task, then keep or revert the change." width="799" height="433"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Ask for the output you will actually use
&lt;/h2&gt;

&lt;p&gt;If your application needs a category and a short explanation, a page of prose is unnecessary output. Define the required fields and expected length before tuning anything else.&lt;/p&gt;

&lt;p&gt;OpenAI's guide recommends optimizing for shorter outputs. My suggestion is to make that concrete in your test: compare the answer your interface needs with the answer you currently request. Remove explanations that nobody sees or uses.&lt;/p&gt;

&lt;p&gt;Do not simply force a tiny output limit on every task. Truncated JSON or an incomplete answer can create retries and extra handling. Verify that your output stays complete, valid, and useful across difficult cases, not only the happy path.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1763568258557-515962e11f38%3Ffm%3Djpg%26q%3D80%26w%3D1200%26auto%3Dformat%26fit%3Dcrop" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimages.unsplash.com%2Fphoto-1763568258557-515962e11f38%3Ffm%3Djpg%26q%3D80%26w%3D1200%26auto%3Dformat%26fit%3Dcrop" alt="Laptop displaying code beside a coffee mug" width="1200" height="800"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Photo by &lt;a href="https://unsplash.com/photos/laptop-screen-displaying-code-next-to-coffee-mug-tiFQ5RxQdT8" rel="noopener noreferrer"&gt;Daniil Komov&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Give a cheaper model a fair test
&lt;/h2&gt;

&lt;p&gt;A lower-priced model is a candidate, not an automatic replacement. OpenAI's guidance is to balance lower cost with maintained accuracy.&lt;/p&gt;

&lt;p&gt;Build a small evaluation set from tasks you are allowed to use. Include routine cases, ambiguous requests, missing information, and the failures you cannot accept. Decide what passing means before seeing the results.&lt;/p&gt;

&lt;p&gt;Then compare the existing model and the candidate on the same tasks. Record successful completions, retries, latency, and cost. If you introduce routing between models, test the routing decision too. Sending a difficult case down the cheap path is part of the system's performance, not a separate excuse.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Match repeated and non-urgent work to the right feature
&lt;/h2&gt;

&lt;p&gt;Two options deserve separate checks: prompt caching and batch processing. They solve different problems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developers.openai.com/api/docs/guides/prompt-caching" rel="noopener noreferrer"&gt;Prompt caching&lt;/a&gt; reuses processing for an eligible matching prompt prefix. Put stable, reusable material before changing request-specific content where the model's documented behavior supports it. Watch actual cache usage rather than assuming that a repeated conversation guarantees a hit.&lt;/p&gt;

&lt;p&gt;Read the selected model's current terms. Minimum lengths, cache lifetimes, and write/read rates matter. A cache write can cost more than ordinary input processing; reuse is what can make the trade worthwhile. Do not add filler just to reach a cache threshold.&lt;/p&gt;

&lt;p&gt;The &lt;a href="https://developers.openai.com/api/docs/guides/batch" rel="noopener noreferrer"&gt;Batch API&lt;/a&gt; is for asynchronous groups of requests that do not need an immediate response. Think offline evaluations or a backlog of documents, not a customer waiting in live chat. Check model support, completion status, and the current processing window before choosing it. A submitted batch is not proof every request succeeded.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep the change only if the task still works
&lt;/h2&gt;

&lt;p&gt;Start with a baseline. Change one lever, run the same evaluation, and compare cost per successful task. Keep the change when it meets your quality and latency requirements; otherwise revert it or narrow where it applies.&lt;/p&gt;

&lt;p&gt;That is the whole discipline: less unnecessary work, not a cheaper-looking request that quietly moves the cost into retries or human cleanup.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Cover photo by &lt;a href="https://unsplash.com/photos/hands-holding-tax-forms-with-calculator-and-laptop-8XrYtOYQDRU" rel="noopener noreferrer"&gt;Kelly Sikkema&lt;/a&gt;, free to use under the Unsplash License.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I write about startups and AI on &lt;a href="https://startupwiki.substack.com" rel="noopener noreferrer"&gt;StartupWiki&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>saas</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
