Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# 1.4.6 - 18 Sep 2025
Improvement:
- [#1406](https://github.com/elysiajs/elysia/issues/1406) strictly check for 200 inline status code
- coerce union status value and return type
- add `BunHTMLBundleLike` to Elysia inline handler
- [#1405](https://github.com/elysiajs/elysia/issues/1405) prevent Elysia from being a dependency of itself
- [#1416](https://github.com/elysiajs/elysia/issues/1416) check if object is frozen before merging, add try-catch to prevent crash
- [#1419](https://github.com/elysiajs/elysia/issues/1419) guard doesn't apply scoped/global schema to object macro
- [#1425](https://github.com/elysiajs/elysia/issues/1425) DELETE doesn't ihnerit derive/resolve type

Change:
- [#1409](https://github.com/elysiajs/elysia/issues/1409) onTransform now doesn't include type as it isn't validated yet, creating confusion

Bug fix:
- [#1410](https://github.com/elysiajs/elysia/issues/1410) handle union derive/resolve property
- probably fix mergeDeep attempted to assign to readonly property
- derive/resolve inherit type in inline handler

# 1.4.5 - 15 Sep 2025
Improvement:
- soundness for guard, group
Expand Down
4 changes: 4 additions & 0 deletions build.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { $ } from 'bun'
import { build, type Options } from 'tsup'
import pack from './package.json'

if ('elysia' in pack.dependencies)
throw new Error("Error can't be a dependency of itself")
Comment on lines +5 to +6
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Harden the self-dependency check (avoid runtime throw, remove magic string, clearer message).
'in' on pack.dependencies throws if dependencies is absent; also hardcoding 'elysia' is brittle. Use pack.name and guard with ?? {}.

Apply this minimal fix:

-if ('elysia' in pack.dependencies)
-	throw new Error("Error can't be a dependency of itself")
+// Guard against missing sections and tie to the actual package name
+if (pack.name in (pack.dependencies ?? {})) {
+	throw new Error(`"${pack.name}" cannot be a dependency of itself`)
+}

Optional: also prevent self‑reference in dev/peer/optional deps:

+const sections = [
+  pack.dependencies,
+  pack.devDependencies,
+  pack.peerDependencies,
+  pack.optionalDependencies
+] as const
+if (sections.some(s => s && (pack.name in s))) {
+  throw new Error(`"${pack.name}" cannot be listed as its own dependency`)
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if ('elysia' in pack.dependencies)
throw new Error("Error can't be a dependency of itself")
// Guard against missing sections and tie to the actual package name
const sections = [
pack.dependencies,
pack.devDependencies,
pack.peerDependencies,
pack.optionalDependencies
] as const
if (sections.some(s => s && (pack.name in s))) {
throw new Error(`"${pack.name}" cannot be listed as its own dependency`)
}
🤖 Prompt for AI Agents
In build.ts around lines 5-6, the current self-dependency check uses the literal
'elysia' and uses the 'in' operator on pack.dependencies which will throw if
dependencies is undefined; replace that with a safe guard and use pack.name for
the package identity: obtain deps = pack.dependencies ?? {} and then check if
pack.name && (pack.name in deps) and throw a clearer error message like `throw
new Error(\`Package "${pack.name}" must not list itself as a dependency\`)`;
optionally repeat the same safe check for devDependencies, peerDependencies and
optionalDependencies (each using the ?? {} guard) to prevent self‑references
there as well.


const external = ['@sinclair/typebox', 'file-type']

Expand Down
9 changes: 3 additions & 6 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
"name": "elysia",
"dependencies": {
"cookie": "^1.0.2",
"elysia": "1.4.3-beta.0",
"exact-mirror": "0.2.2",
"fast-decode-uri-component": "^1.0.1",
},
"devDependencies": {
"@elysiajs/openapi": "^1.3.11",
"@types/bun": "^1.2.16",
"@elysiajs/openapi": "^1.4.1",
"@types/bun": "^1.2.12",
"@types/cookie": "^1.0.0",
"@types/fast-decode-uri-component": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^8.30.1",
Expand Down Expand Up @@ -47,7 +46,7 @@

"@ark/util": ["@ark/util@0.49.0", "", {}, "sha512-/BtnX7oCjNkxi2vi6y1399b+9xd1jnCrDYhZ61f0a+3X8x8DxlK52VgEEzyuC2UQMPACIfYrmHkhD3lGt2GaMA=="],

"@elysiajs/openapi": ["@elysiajs/openapi@1.3.11", "", { "dependencies": { "@sinclair/typemap": "^0.10.1", "openapi-types": "^12.1.3" }, "peerDependencies": { "elysia": ">= 1.3.0" } }, "sha512-+jwAEIDbIGmSKjl/kePwdDaHFgsIX/cEpw01sSjzm7SosjwZuQjJDVgDCab2p68lIO+VUOsvkKuP+5Sm5ehCvQ=="],
"@elysiajs/openapi": ["@elysiajs/openapi@1.4.2", "", { "peerDependencies": { "elysia": ">= 1.4.0" } }, "sha512-i+9YYVmX9Qx40dGRI9DE9zZJrEo4qXo5h2lfuxf1WuQZKYY8RonnYQZYbdWr/Azs8upTfIdyCifgjfu3Cht8rw=="],

"@esbuild/aix-ppc64": ["@esbuild/aix-ppc64@0.25.4", "", { "os": "aix", "cpu": "ppc64" }, "sha512-1VCICWypeQKhVbE9oW/sJaAmjLxhVqacdkvPLEjwlttjfwENRSClS8EjBz0KzRyFSCPDIkuXW34Je/vk7zdB7Q=="],

Expand Down Expand Up @@ -189,8 +188,6 @@

"@sinclair/typebox": ["@sinclair/typebox@0.34.41", "", {}, "sha512-6gS8pZzSXdyRHTIqoqSVknxolr1kzfy4/CeDnrzsVz8TTIWUbOBr6gnzOmTYJ3eXQNh4IYHIGi5aIL7sOZ2G/g=="],

"@sinclair/typemap": ["@sinclair/typemap@0.10.1", "", { "peerDependencies": { "@sinclair/typebox": "^0.34.30", "valibot": "^1.0.0", "zod": "^3.24.1" } }, "sha512-UXR0fhu/n3c9B6lB+SLI5t1eVpt9i9CdDrp2TajRe3LbKiUhCTZN2kSfJhjPnpc3I59jMRIhgew7+0HlMi08mg=="],

"@tokenizer/inflate": ["@tokenizer/inflate@0.2.7", "", { "dependencies": { "debug": "^4.4.0", "fflate": "^0.8.2", "token-types": "^6.0.0" } }, "sha512-MADQgmZT1eKjp06jpI2yozxaU9uVs4GzzgSL+uEq7bVcJ9V1ZXQkeGNql1fsSI0gMy1vhvNTNbUqrx+pZfJVmg=="],

"@tokenizer/token": ["@tokenizer/token@0.3.0", "", {}, "sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A=="],
Expand Down
23 changes: 12 additions & 11 deletions example/a.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { Elysia, t } from '../src'
import z from 'zod'
import { req } from '../test/utils'

const app = new Elysia()
.macro('guestOrUser', {
resolve: () => {
return {
user: null
new Elysia()
.macro({
token: {
resolve: () => {
return {
__token: '123'
}
}
}
})
.macro('user', {
guestOrUser: true,
body: t.String(),
resolve: ({ body, status, user }) => {}
.macro('some', {
token: true,
beforeHandle: ({ __token }) => {
console.log('__token', __token)
}
})
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elysia",
"description": "Ergonomic Framework for Human",
"version": "1.4.5",
"version": "1.4.6",
"author": {
"name": "saltyAom",
"url": "https://github.com/SaltyAom",
Expand Down Expand Up @@ -184,13 +184,12 @@
},
"dependencies": {
"cookie": "^1.0.2",
"elysia": "1.4.3-beta.0",
"exact-mirror": "0.2.2",
"fast-decode-uri-component": "^1.0.1"
},
"devDependencies": {
"@elysiajs/openapi": "^1.3.11",
"@types/bun": "^1.2.16",
"@elysiajs/openapi": "^1.4.1",
"@types/bun": "^1.2.12",
"@types/cookie": "^1.0.0",
"@types/fast-decode-uri-component": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^8.30.1",
Expand Down
9 changes: 2 additions & 7 deletions src/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ const emptyHttpStatus = {

export class ElysiaCustomStatusResponse<
const in out Code extends number | keyof StatusMap,
in out T = Code extends keyof InvertedStatusMap
// no in out here so the response can be sub type of return type
T = Code extends keyof InvertedStatusMap
? InvertedStatusMap[Code]
: Code,
const in out Status extends Code extends keyof StatusMap
Expand Down Expand Up @@ -79,12 +80,6 @@ export const status = <
response?: T
) => new ElysiaCustomStatusResponse<Code, T>(code, response as any)

const a = status(403, 'a')
const b = status(403, 'b')

type a = typeof a
type b = typeof b

export class InternalServerError extends Error {
code = 'INTERNAL_SERVER_ERROR'
status = 500
Expand Down
Loading
Loading