Timed with AWS re:Invent 2026, the new AWS Amplify (Amplify Gen 3) was introduced on About Amazon, Amazon's official news site, on November 30, 2026 (US time). The source code for the per-framework adapters, the client SDK, and more is public in a GitHub repository.

https://www.aboutamazon.com/news/aws/what-is-aws-amplify

https://github.com/aws-amplifygen3/amplifygen3

Partly because I help run the Amplify Japan User Group, I started reading the adapter source code in this freshly published repository on the afternoon of December 1 (Japan time). That is where I found a bug in the SvelteKit adapter. The adapter was converting the URLs of pages that SvelteKit generated at build time as if they were "dynamic route definitions." As a result, when a URL contains parentheses, asterisks, or square brackets, a different page comes back with HTTP 200, or a page matches a URL that does not exist.

I reproduced the bug with a minimal SvelteKit app built for verification, then built the same app with the adapter before and after the fix. I compared the outputs both on the local emulator and on AWS before opening the PR. The PR was merged on December 5 after review.

https://github.com/aws-amplifygen3/amplifygen3/pull/118

The first half of this article covers, in order, the cause of the bug and reproduction steps you can try yourself, a gap in my first fix that unit tests did not catch, a before-and-after comparison on AWS, and the checks I ran before opening the PR.

The second half covers two examples of applying the same approach to fixes in other adapters and the SDK. One is how I checked, in a fix to the Nuxt adapter, that my change did not break cases that used to work correctly (that it did not regress). The other is a decision to fold a related fix into an existing PR and to hold off on opening new PRs for a while.

I did the work with a coding agent and kept the main commands and their output in logs, including the ones that failed. The numbers and responses below are based on those logs and the HTTP responses I saved.

Amplify Gen 3 adapters and route evaluation order

In Gen 3, a per-framework adapter converts the build output into a .amplify/ folder. The routes are listed in deployment-manifest.json inside it. A route pairs a regular expression that matches the request path (source) with how to respond when it matches. Ways to respond include returning pre-generated HTML and passing the request to compute, the server-side processing.

Unconditional static, rewrite, and compute delivery routes are evaluated from top to bottom, and the first matching route decides how to respond. You can confirm this evaluation order in the emulator's implementation, and it is consistent with the results on AWS shown later. So if the routes an adapter generates are wrong, users can see a different page from the URL they opened even when the app's code is correct.

I explained how to read routes and how to check the output with the local emulator in detail in this article:

https://dev.to/aws-builders/how-amplify-gen-3-hosting-works-and-how-to-verify-it-adapters-route-evaluation-order-and-the-4g1o

SvelteKit prerendered pages and the routes the adapter generates

In SvelteKit, pages with dynamic parameters such as [slug] can also be generated at build time (prerendered). You set prerender = true and return the parameters you want to generate from an entries function.

https://github.com/sveltejs/kit/blob/@sveltejs/kit@3.1.1/documentation/docs/20-core-concepts/40-page-options.md

In the verification app, I specified four parameters for the /cases/[slug] page, mostly values that contain symbols.

// src/routes/cases/[slug]/+page.server.js export const prerender = true; export function entries() { return ['normal', 'release(1)', 'file*', '[slug]'].map((slug) => ({ slug })); } export function load({ params }) { return { slug: params.slug, marker: `prerendered:${params.slug}` }; } 

The last one, '[slug]', uses a string containing square brackets as the parameter value as is. When you build, four pages are generated as HTML files: /cases/normal, /cases/release(1), /cases/file*, and /cases/[slug]. Pages for values not listed in entries (for example /cases/unrelated) are not generated.

For each URL of a generated page that it receives from SvelteKit (builder.prerendered.paths), the SvelteKit adapter writes a route into deployment-manifest.json that returns the pre-generated HTML for requests to that URL (rewrite). Requests that match none of these routes are passed to the SvelteKit server (compute) by the last route, ^/.*$.

A different page returned with HTTP 200, and why

When I built the verification app with the adapter on main at the time (the "before" adapter from here on), requests to /cases/release(1) did not return the release(1) page but the square-bracket page (/cases/[slug]). Conversely, opening /cases/release1, which should not exist, showed the release(1) page. Both return status 200, so you would not notice by looking at status codes alone.

The cause was in the adapter's manifest_generator.ts. At the main commit I used for verification (7afe79175d63747b428b16403656bc7367fab4e7), the URLs of generated pages were converted into regular expressions by a function called convertRoutePattern.

// packages/adapters/js/packages/sveltekit/src/adapter/manifest_generator.ts (before the fix) const prerenderedPaths = new Set(builder.prerendered.paths); for (const pagePath of prerenderedPaths) { if (builder.prerendered.redirects.has(pagePath)) continue; const pattern = convertRoutePattern(pagePath); validateRouteRegex(pattern); 

convertRoutePattern is a function for turning dynamic route definitions like /cases/[slug] into regular expressions. But builder.prerendered.paths contains concrete, already generated URLs such as /cases/release(1). Because concrete URLs were treated as dynamic route definitions, square brackets were interpreted as parameters, and parentheses and asterisks as regular expression symbols.

Here are the page routes extracted from the deployment-manifest.json produced by the before adapter:

Generated page source before the fix What it matches as a regular expression
/cases/normal ^/cases/normal$ Only /cases/normal
/cases/release(1) ^/cases/release(1)$ (1) becomes a group and matches /cases/release1. Does not match /cases/release(1)
/cases/file* ^/cases/file*$ e* becomes "zero or more e's" and matches /cases/fileeeee and so on. Does not match /cases/file*
/cases/[slug] ^/cases/([^/]+)$ [slug] is converted into the parameter ([^/]+) and matches any path directly under /cases/

So requests to /cases/release(1) did not match the route created for the release(1) page, and were picked up by the route for the [slug] page, which broadly matches anything directly under /cases/. Meanwhile, the nonexistent /cases/release1 matched the route for the release(1) page.

The fix was to also use exactPathPattern for generated pages. This function already existed in the adapter and escapes every symbol in a path to match it exactly. The PR swaps this one call. In the end I also changed exactPathPattern itself, and I explain why in a later section.

- const pattern = convertRoutePattern(pagePath); + const pattern = exactPathPattern(pagePath); 

A verification setup that compares the before and after adapters under the same conditions

To show the effect of the fix, everything except the adapter has to be the same before and after. So I used the same verification app and the same lockfile, and built it twice, switching only the adapter. Here is the environment I used:

Item Details
Gen 3 repository main at commit 7afe79175d63747b428b16403656bc7367fab4e7
Node.js and npm v22.23.5 and 10.9.9
SvelteKit @sveltejs/kit 3.1.1
Other dependencies @sveltejs/vite-plugin-svelte 7.0.0, svelte 5.57.1, vite 8.2.1
Adapter @aws-amplifygen3/adapter-sveltekit 1.0.0 (both before and after built from the commit above)

The before and after adapters both have package version 1.0.0, so you cannot tell them apart by version. I recorded SHA-256 hashes of the packages I built (tgz) and of manifest_generator.ts, so I could confirm later which one was used.

1. Building packages of the before and after adapters

First, clone the Gen 3 repository and check out the commit used for verification. Then install dependencies and build in the packages/adapters/js folder, which holds the adapters.

git clone https://github.com/aws-amplifygen3/amplifygen3.git cd amplifygen3 git checkout 7afe79175d63747b428b16403656bc7367fab4e7 cd packages/adapters/js npm ci # The first time, also build the internal dependency packages in dependency order npm run build 

The final npm run build builds all the adapters together. Building the SvelteKit adapter needs the build output of packages in the same repository, such as bundle-tools, so installing dependencies alone is not enough. From the second time on, you can rebuild just the SvelteKit adapter.

Next, build the before adapter and package it with npm pack. The commands are:

# Run in packages/adapters/js npm run build -w packages/sveltekit # Run in packages/adapters/js/packages/sveltekit npm pack --ignore-scripts \ --cache /tmp/amplifygen3-repro-npm-cache \ --pack-destination /path/to/repro/vendor/before 

--cache is an option to use an npm cache dedicated to this verification. When I first ran it without --cache, writing to my usual npm cache failed with a permission error (EPERM). npm showed its message for the case where the cache contains files created with root privileges, but I did not look into the actual cause. Instead of touching the permissions of my usual cache, I specified a dedicated cache and ran it again.

Then replace manifest_generator.ts with the PR's version and build the after package with the same two commands, saving it to a separate folder such as vendor/after. This time I replaced the file's contents with a script, but if you try it yourself, running git apply with the PR's diff at the top of the repository is probably the easiest way.

2. A verification SvelteKit app that can switch between the two adapters

In the verification app's package.json, install the before and after packages under different names, amplify-adapter-before and amplify-adapter-after. With both installed at once, you don't need to reinstall dependencies every time you switch adapters, and the versions of the other dependencies stay pinned by the lockfile.

{ "name": "amplify-gen3-sveltekit-prerender-repro", "private": true, "type": "module", "scripts": { "build": "vite build" }, "devDependencies": { "amplify-adapter-before": "file:../vendor/before/aws-amplifygen3-adapter-sveltekit-1.0.0.tgz", "amplify-adapter-after": "file:../vendor/after/aws-amplifygen3-adapter-sveltekit-1.0.0.tgz", "@sveltejs/kit": "3.1.1", "@sveltejs/vite-plugin-svelte": "7.0.0", "svelte": "5.57.1", "vite": "8.2.1" } } 

In SvelteKit 3, you pass the adapter to sveltekit() in vite.config.js. With the following settings, the before adapter is used when the environment variable ADAPTER_VARIANT is before, and the after adapter when it is after or unset.

// vite.config.js import before from 'amplify-adapter-before'; import after from 'amplify-adapter-after'; import { sveltekit } from '@sveltejs/kit/vite'; import { defineConfig } from 'vite'; const variant = process.env.ADAPTER_VARIANT ?? 'after'; if (!['before', 'after'].includes(variant)) throw new Error('Unknown ADAPTER_VARIANT'); export default defineConfig({ plugins: [sveltekit({ adapter: (variant === 'before' ? before : after)() })] }); 

Besides the /cases/[slug] page above, I prepared two more pages: a prerendered top page (/) and an SSR page (/live) to confirm that requests reach compute. So that the response body tells you which page it is, each page embeds an identifier in a data-marker attribute.

<!-- src/routes/cases/[slug]/+page.svelte --> <script>let { data } = $props();</script> <svelte:head><title>Prerendered: {data.slug}</title></svelte:head> <h1>Prerendered page</h1> <p data-marker={data.marker}>{data.marker}</p> <a href="/">Home</a> 
// src/routes/live/+page.server.js export const prerender = false; export function load() { return { marker: 'dynamic:live' }; } 

The top page embeds the identifier home and /live embeds dynamic:live, in the same data-marker attribute.

3. Two builds with different adapters, and saving the output

Install dependencies in the verification app's folder and build twice, changing the environment variable ADAPTER_VARIANT. Each build overwrites the .amplify/ folder, so copy it to a separate folder after each build.

npm ci ADAPTER_VARIANT=before npm run build cp -R .amplify ../outputs/before ADAPTER_VARIANT=after npm run build cp -R .amplify ../outputs/after 

Comparing the two saved deployment-manifest.json files, the only difference was the routes' source. After the fix, / is escaped too, so the notation also changes for routes of pages without symbols such as /cases/normal, but the URLs they match stay the same. The URLs matched changed only for routes of pages with symbols. The main ones are:

- "source": "^/cases/release(1)$", + "source": "^\\/cases\\/release\\(1\\)$", - "source": "^/cases/file*$", + "source": "^\\/cases\\/file\\*$", - "source": "^/cases/([^/]+)$", + "source": "^(?:\\/cases\\/\\[slug\\]|\\/cases\\/%5Bslug%5D)$", 

Since these are JSON strings, \\ stands for a single \. Before the fix, (1) and * remain as regular expression symbols, and [slug] turns into the parameter ([^/]+). After the fix, symbols are escaped as in \( and \*, and match as literal URL characters. The %5Bslug%5D after the | on the last line is the URL-encoded form of the square brackets. I explain why this form became necessary in a later section.

4. Comparing before and after responses on the emulator

The Gen 3 repository includes an emulator that reads a .amplify/ folder and reproduces Amplify hosting behavior locally. The emulator was built along with the adapters in step 1. Start it once for before and once for after, pointing --output-dir to the saved output folder.

node /path/to/amplifygen3/packages/adapters/js/packages/deployment-manifest/dist/cjs/emulator/hosting-emulator.js \ --output-dir /path/to/repro/outputs/before --port 8085 

After it starts, wait until /live responds before sending requests. I explain why in the next section. I checked these 10 paths:

  • Pages without symbols: /, /live, /cases/normal
  • Generated pages with symbols: /cases/release(1), /cases/file*, /cases/[slug], /cases/%5Bslug%5D
  • Paths that do not exist and should return 404: /cases/release1, /cases/fileeeee, /cases/unrelated

This time I saved the status, headers, body, and data-marker with a Python script, but you can also check with curl if you are trying it by hand. curl tries to expand square brackets in URLs as ranges such as [1-3], similar to a regular expression character class, so /cases/[slug] fails as is. With --globoff, square brackets are sent as literal characters.

curl --globoff -i 'http://localhost:8085/cases/release(1)' curl --globoff -i 'http://localhost:8085/cases/release1' curl --globoff -i 'http://localhost:8085/cases/%5Bslug%5D' # Extract just the identifier from the body curl --globoff -s 'http://localhost:8085/cases/release(1)' | grep -o 'data-marker="[^"]*"' 

Check the data-marker in the body as well as the status code. As shown later, all five failures before the fix came back as HTTP 200, so the status alone cannot tell you what went wrong.

502s from requests right after the emulator started

The emulator comparison did not work on the first try.

The first time, the verification script hit PermissionError: [Errno 1] Operation not permitted when it tried to reserve a local port. This came from a restriction of the coding agent's working environment, so I allowed port use and ran it again.

The second time, /live returned 502 both before and after the fix, and after the fix every path that should go to compute returned 502 as well.

At that point, the script considered the emulator ready as soon as the static top page responded. But the emulator starts accepting requests before compute is ready. Sending requests before compute finished starting is the likely cause of the 502s. How the emulator starts up is outside the scope of this fix, so rather than pinning down the cause, I dealt with it by changing how the script waits. Once I changed the script to wait until /live, which runs on compute, returned something other than a server error (5xx) such as 502, the 502s stopped.

At the same time, I revisited which paths to check. The /cases/[slug] page can be reached by two spellings: /cases/[slug] with the square brackets written as is, and the URL-encoded /cases/%5Bslug%5D. I had been treating these as one case; I started checking them separately, which brought the number of paths to 10.

A missed URL-encoded spelling that unit tests did not catch

In the third comparison, after making the script wait for compute to start, I found that the fix at that point (the "first fix" from here on) was also incomplete. With the first fix's adapter, only /cases/%5Bslug%5D returned 404.

Path Before the fix First fix
/cases/[slug] 200, the square-bracket page 200, the square-bracket page
/cases/%5Bslug%5D 200, the square-bracket page 404

The first fix only swapped the function that builds routes for generated pages from convertRoutePattern to exactPathPattern. The generated regular expression was ^\/cases\/\[slug\]$, which only matches the path with the square brackets written as is. The URL-encoded path matched no route, went to compute, and the SvelteKit server returned 404. The response carried the x-sveltekit-page: true header, which shows it came from the SvelteKit server.

With the before adapter, this path returned the correct page with 200. But that was only because [slug] was converted into ([^/]+) and matched any path directly under /cases/. The first fix had broken a case that used to pass by accident, thanks to the wrong conversion. In the verification app too, the link from the top page to the square-bracket page is written as /cases/%5Bslug%5D. When a user clicks that link, the request uses the URL-encoded spelling, and the first fix would return 404.

The reason unit tests did not catch this lies in how the test was written. The first fix's test passed /[slug] as the URL of a generated page and checked that the same string /[slug] matched the route.

// Test added in the first fix (excerpt) expect(routeFor(urlPath)?.target.kind).toBe("rewrite"); expect(routeFor("/release1")?.target.kind).toBe("compute"); 

In other words, the test did not cover enough. In real HTTP requests, the spelling of a request to the same page changes depending on whether it is encoded. Yet I had built both the test input and the expected result only from the spelling I had in mind, with the square brackets written as is. By building a real app and sending real HTTP requests, I noticed a spelling the test had not anticipated.

In the additional fix, exactPathPattern matches two spellings: the path as written, and the path with each segment encoded by encodeURIComponent. Regular expression symbols are escaped in both.

// manifest_generator.ts (the merged fix) /** Matches a concrete path in its decoded or URL-encoded spelling. */ export function exactPathPattern(urlPath: string): string { const encoded = urlPath.split("/").map(encodeURIComponent).join("/"); const escaped = escapeRegex(urlPath); return encoded === urlPath ? `^${escaped}$` : `^(?:${escaped}|${escapeRegex(encoded)})$`; } 

During review, the regular expression escaping (escapeRegex) was moved into a separate file, escape_regex.ts. Its logic did not change.

Paths whose spelling does not change when encoded (such as /cases/normal) still match a single spelling as before. Because the two spellings are wrapped as a whole in ^(?:…)$, a match on only part of the path cannot happen either.

I added test cases checking that paths containing square brackets, spaces, Japanese, ?, and # match both spellings, and that unrelated paths, or paths with something appended after them, do not match.

// manifest_generator.test.ts (part of the added tests) describe("encoded concrete paths", () => { it.each([ "/cases/[slug]", "/notes [draft].html", "/日本語", "/question?.html", "/hash#.html", ])( "matches both spellings of %s without interpreting regex metacharacters", (urlPath) => { const pattern = new RegExp(exactPathPattern(urlPath)); expect(pattern.test(urlPath)).toBe(true); expect( pattern.test(urlPath.split("/").map(encodeURIComponent).join("/")), ).toBe(true); expect(pattern.test("/unrelated")).toBe(false); expect(pattern.test(urlPath + "/extra")).toBe(false); }, ); }); 

After confirming that the 22 tests in manifest_generator.test.ts passed, I rebuilt the adapter with the additional fix, rebuilt the app, and checked the 10 paths on the emulator. Every response was as expected. I also kept the first fix's package and its hashes separately, so I can trace later which version of the fix produced which result.

Comparing before and after on real AWS

The emulator reproduces hosting behavior locally, so it does not necessarily behave exactly like the real Amplify Gen 3. So I also deployed the same outputs I ran on the emulator to AWS, and compared before and after with the same 10 paths.

Getting an AWS CLI that supports aws amplifygen3

My local AWS CLI was 2.40.4, and it did not recognize aws amplifygen3 as a command. According to the AWS CLI changelog, aws amplifygen3 was added in 2.43.0. So I downloaded the macOS installer (pkg) from the official URL, but checking its signature with pkgutil --check-signature showed invalid signature, so I decided not to run that installer.

Instead, I fetched the AWS CLI source published on GitHub (2.43.0 on the v2 branch) into a temporary folder and ran it with the Python environment of my local AWS CLI. I left my local AWS CLI as it was, without overwriting it.

With this approach, I confirmed that aws amplifygen3 could show its help and list apps. I used a dedicated AWS account for verification, and after signing in with SSO, I confirmed with aws sts get-caller-identity that I was in that account.

Creating the app on AWS and deploying with --prebuilt

First, I confirmed there were no apps at all in the Tokyo Region (ap-northeast-1). This was so that during cleanup I would not mix up what I created for verification with other apps or resources. Then I created a temporary app on AWS for verification. It does not use a database or user authentication, so no backend is configured. I created the app from a folder containing the following configuration file, amplify.jsonc.

// amplify.jsonc { "name": "<app-name>", "deploy": { "install": "true", "build": "true", "output_directory": ".amplify" } } 

With --prebuilt, no build runs in the cloud, so the install and build values here are not an example of a normal app's build settings. For <verification-profile>, specify a named AWS CLI profile that points to the verification account.

aws amplifygen3 create --name <app-name> --yes \ --profile <verification-profile> --region ap-northeast-1 

Running create created two environments, preview and production, and an IAM role for the app.

For deployment I used --prebuilt. According to the AWS CLI help, --prebuilt deploys output you built locally as is, instead of uploading the source and building it in Amplify. Dependencies are not reinstalled either. So the same outputs I ran on the emulator can be compared as is on AWS. If you don't specify an environment, deploy deploys to the preview environment.

aws amplifygen3 deploy --prebuilt /path/to/outputs/before --logs \ --profile <verification-profile> --region ap-northeast-1 

At first I added --watch, intending to wait for completion, but it failed with Unknown options: --watch. It stopped at argument validation, so nothing was uploaded or deployed. Reading the argument definitions in the AWS CLI source, I found that deploy waits until completion without any option, and that you use --logs to show the deployment logs. --watch is an option of aws amplifygen3 deployment get.

After deploying the before outputs to the preview environment and checking the 10 paths, I deployed the after outputs to the same preview environment and checked the same 10 paths at the same URL. According to the AWS CLI logs, each deployment finished in a little over ten seconds.

Before and after differences confirmed on AWS

Here are the results I checked in the Tokyo Region on December 1, 2026. Values in the table such as home, normal, and [slug] are the data-marker values embedded in the body of the returned page, and show which page was displayed. The prerendered: prefix on generated pages' values is omitted.

Path Expected Before the fix After the fix
/ 200, home 200, home 200, home
/live 200, dynamic:live 200, dynamic:live 200, dynamic:live
/cases/normal 200, normal 200, normal 200, normal
/cases/release(1) 200, release(1) 200 but the [slug] page 200, release(1)
/cases/file* 200, file* 200 but the [slug] page 200, file*
/cases/[slug] 200, [slug] 200, [slug] 200, [slug]
/cases/%5Bslug%5D 200, [slug] 200, [slug] 200, [slug]
/cases/release1 404 200 though it does not exist (the release(1) page) 404
/cases/fileeeee 404 200 though it does not exist (the file* page) 404
/cases/unrelated 404 200 though it does not exist (the [slug] page) 404

Before the fix, 5 of the 10 paths gave results different from what was expected; after the fix, all of them were as expected. The final results on the emulator were the same as this table.

Before the fix, /cases/release(1) and /cases/file* also had Prerendered: [slug] as their HTML <title>. Even when the status looks like a success, the body shows it is a different page. /cases/[slug] and /cases/%5Bslug%5D were as expected even before the fix, but as mentioned earlier, they matched by accident because of the wrong conversion. The after adapter generates the intended exact-match routes.

The headers differed too. After the fix, the 404 responses had x-sveltekit-page: true. This is consistent with them matching no generated page route, being passed to compute by the last route, and being returned by the SvelteKit server. Responses such as /cases/release1 that returned 200 before the fix did not have this header.

For each request, I saved the status, headers, body, and a hash of the body. The body hash differed between before and after for every path, which also shows that the after check was looking at responses from the newly deployed outputs.

However, for the URL-encoded /cases/%5Bslug%5D, the table alone does not tell you whether the fix had an effect. Both before and after, this response carried X-Amplify-Cache: Hit, and its body hash was the same as the /cases/[slug] request made just before. Amplify's cache may have treated the two spellings as the same and served the response from the cache. So these records cannot tell whether the URL-encoded spelling matched the adapter's regular expression on AWS. That the first fix misses the URL-encoded spelling is a result I confirmed on the emulator.

Deleting the app on AWS and checking for leftover resources

After verification, I deleted the app I had created on AWS and confirmed that no related resources remained.

aws amplifygen3 app delete --app <app-name> --yes \ --profile <verification-profile> --region ap-northeast-1 aws amplifygen3 app list \ --profile <verification-profile> --region ap-northeast-1 

When you run app delete, it tells you that CloudWatch Logs log groups under /aws/amplifygen3/<app-name>/ are not deleted and remain, and that you should delete them if you don't need them. I deleted the two log groups created during verification with aws logs delete-log-group, then listed again with the same prefix and confirmed it was empty.

I confirmed that the IAM role was gone by searching for it by name. Note that the names of roles the CLI creates use the first 18 characters of the app name.

aws iam list-roles --profile <verification-profile> \ --query "Roles[?starts_with(RoleName, 'Amplify-<first-18-characters-of-app-name>-')].RoleName" \ --output json 

In the end, the app list showed "No apps found in this account and region.", and the searches for log groups and IAM roles came back empty as well. I covered points to watch out for when deleting an app that uses a backend in the article on how hosting ...