Three Production Problems Local Tests Missed
I had been checking that the app started on the production Mac as well as running tests. Even so, three problems appeared over the three days around the Flyway switch in Part 3.
Flyway never ran. A build that passed locally failed in Docker. The cache problem took longer to notice: pages returned 200 while every attempt to write the cache to disk failed.
A boot test without production credentials
On the Spring side, there has been a test with an empty method body since the beginning. Running it still loads the Spring context.
@SpringBootTestclass BlogApiApplicationTests { @Test void contextLoads() { }}Slice tests such as @WebMvcTest and @DataJpaTest load only part of the context, so they can miss problems that only surface when the full context is assembled. This test loads the full context using a test token and H2, without production credentials or the production database and guards one thing: does the app assemble? On top of that, every time I finished a feature step, I started the containers for real on the production Mac and checked through the public URL.
The test setup still differed from the actual containers.
Case 1. Flyway never ran at all
I added two Flyway libraries and started the app on the production Mac. Boot kept failing.
runtimeOnly 'org.flywaydb:flyway-core'runtimeOnly 'org.flywaydb:flyway-database-postgresql'Schema-validation: missing table [categories]Hibernate was trying to check the schema with validate, but the table didn't exist. The odd part was that the log had not a single Flyway line. The migration hadn't failed. It had never been attempted.
In Spring Boot 2 and 3, Flyway support was included in the main auto-configuration module. Starting with Spring Boot 4.0, auto-configuration was split into per-feature modules, and Flyway's auto-configuration moved into a separate module called spring-boot-flyway. [S1] That module was missing from my 4.1 setup. I had no configuration to invoke Flyway directly either, so adding the libraries alone did not start migrations.
Here is how I found it. I opened the running jar and confirmed there was no class with Flyway in its name inside spring-boot-autoconfigure. Then I searched the Spring Boot dependency list (the BOM) for flyway and found an artifact named spring-boot-flyway.
Adding the missing auto-configuration module
runtimeOnly 'org.springframework.boot:spring-boot-flyway'In the test environment
As decided in Part 3, the tests used H2 with Flyway turned off, and Hibernate created the test schema. In the test environment, Flyway not running was the expected state, so the tests had no way to notice that Flyway wasn't running in production.
After that, I also checked for lines such as Successfully applied 1 migration or Current version of schema. An error-free log did not tell me whether Flyway had run.
Case 2. Green local build, broken Docker build
While adding a table of contents and code highlighting, I added four frontend dependencies. Local tests and next build all passed. But npm ci in the Docker image build step failed with an EUSAGE error saying package.json and package-lock.json were out of sync.
The public page still used the old image
The new table of contents and highlighting were missing from the public page. My notes attributed this to an old dependency layer and image still being used. The build inputs and cache-decision logs were not preserved, though, so I cannot establish exactly where the old image was retained.
Docker includes changes to files used by COPY in its cache checks. [S2] This incident should not be read as evidence that Docker always reuses an old install layer after package files change.
The npm that created the lockfile and the npm that checked it were different. The package-lock.json created by npm 11 on the host Mac was rejected by npm 10 in the container (node:20-alpine). The notes attributed the mismatch to differences in handling the @emnapi/* optional dependency subtree. But the macOS and Linux installation environments also differed; this was not an experiment that isolated the npm version alone.
For the moment, I regenerated the lockfile in the same environment as the container.
docker run --rm -v "$PWD/blog-web":/app -w /app node:20-alpine \ npm install --package-lock-onlyThe same problem happened once more two months later, when I added a library for rendering tables. That time I moved the container image to node:24-alpine and made it retry with npm install if npm ci failed.
FROM node:24-alpine AS deps...RUN npm ci --no-audit --no-fund || npm install --no-audit --no-fundThis retry does not replace strict lockfile validation. npm ci fails on a mismatch without changing the lockfile, while npm install can resolve dependencies again and update it. [S3] This Dockerfile retries regardless of why ci failed. In the later October 20 deployment record, I separately confirmed that npm ci passed without using the fallback.
In the test environment
Local tests and local builds run on top of node_modules installed with the host's npm. The npm and Node versions the production image uses never appear in that process. A green local build did not mean a green Docker build. Since then, when I suspect dependencies, I build with --no-cache or check the node_modules inside the container directly.
Case 3. Responses were 200 while cache writes failed
The day before, I had added ISR caching with a 60-second revalidation interval, and checked it as follows. The interval does not schedule regeneration every 60 seconds; a request after the interval triggers revalidation. [S4] My check was this: with the API completely shut down, the home page, category pages, and sitemap still rendered with 200, so I concluded the cache was working.
The next day, while checking a different feature, I found EACCES in the web container's logs. At runtime, it was trying to create the .next/cache directory and failing every time for lack of permission. Writes to this cache path were failing, yet responses stayed at 200.
The image's run stage switches to a non-root user, nextjs, for security. But the .next directory had been copied in as root-owned, so nextjs couldn't create cache under it.
I couldn't confirm from the records why the previous day's check passed. My guess is that even though disk writes failed, the process answered from a cache held in memory. What is certain is that the "200 even with the API down" check could not tell whether the disk cache was being written.
Before switching USER, I created .next owned by nextjs and set the owner on the copied files as well.
-COPY --from=build /app/.next/standalone ./+RUN mkdir .next && chown nextjs:nodejs .next+COPY --from=build --chown=nextjs:nodejs /app/.next/standalone ./ USER nextjsAfter rebuilding, I checked that .next/cache/fetch-cache was created inside the container owned by nextjs, and that the logs showed zero EACCES.
In the test environment
Tests and local runs execute under my own user account, which can write to .next freely. The permission problem only exists when running as a non-root user inside the image. Checking page responses alone would have missed it.
That experience paid off two months later when I built image uploads. The upload volume also needed to be writable by the process user. I created its mount-point directory and set ownership before the USER switch, then checked ownership and write access in a container with the volume mounted.
The three cases side by side
| Case | Environment the tests saw | Actual production environment | What was visible |
|---|---|---|---|
| Flyway never ran | H2, Flyway off | PostgreSQL, Flyway required | Missing-table error, zero Flyway log lines |
npm ci failure | Installed with host npm 11 | Installed with container npm 10 | New UI missing; EUSAGE during image build |
| Cache write failure | My account, with write access | Non-root user, no access | 200 responses, EACCES only in logs |
These tests did not check production Flyway execution, dependency installation inside the container, or the runtime user's write access. They passed within the conditions and checks they actually covered.
What I also check during deployment
I kept the full-context test that runs without production credentials. For production checks, I start containers built from the same Dockerfile and compose configuration, then open the public URL. I also inspect migration logs and cache directories. In particular, status codes alone could not tell me whether cache writes worked.
The next post looks at why I enabled this cache and the two layers where Next.js stores data.
Sources
- [S1] Spring Boot 4.0 Migration Guide | Checked 2026-11-07 | https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide ↩
- [S2] Build cache invalidation | Docker Docs | Checked 2026-11-07 | https://docs.docker.com/build/cache/invalidation/ ↩
- [S3] npm ci | npm Docs | Checked 2026-11-07 | https://docs.npmjs.com/cli/v11/commands/npm-ci/ ↩
- [S4] Incremental Static Regeneration | Next.js | Checked 2026-11-07 | https://nextjs.org/docs/app/guides/incremental-static-regeneration ↩
About these records
This post covers three cases I ran into between June 30 and July 2, 2026, based on my work notes from the time and the actual diffs of the fixing commits. It also includes follow-up changes from August and a build check recorded on October 20. Where a cause isn't confirmed by the records, I mark it as a guess.
Report an error or share feedback
Open a draft with this article’s title and URL. Review the message and recipient before sending.
Open email draftIf no email app opens, copy these details into your usual email service.
Related posts
Backend & Infrastructure Spring Boot 4.1 Jackson Settings: Comparing Duplicate JSON Keys and BigDecimal Output
Compare two Jackson settings in the same Spring Boot 4.1.0 app using the recorded six tests and six HTTP requests for duplicate JSON keys and BigDecimal notation.
Backend & Infrastructure A Spring Backend Learning Roadmap: Seven Skills to Demonstrate with a Small Service
A fictional reading-log service connects practice tasks and completion criteria for business rules, HTTP, transactions, permissions, queries, tests, and operations.