Skip to content

Commit a6684af

Browse files
committed
fix(templates): add null checks for template config properties
Prevent potential runtime errors by adding null checks for domains, env, and mounts in template processors
1 parent 8df2b20 commit a6684af

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

apps/dokploy/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dokploy",
3-
"version": "v0.20.0",
3+
"version": "v0.20.1",
44
"private": true,
55
"license": "Apache-2.0",
66
"type": "module",

packages/server/src/templates/processors.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,9 @@ export function processDomains(
175175
variables: Record<string, string>,
176176
schema: Schema,
177177
): Template["domains"] {
178-
return template.config.domains.map((domain: DomainConfig) => ({
178+
if (!template?.config?.domains) return [];
179+
180+
return template?.config?.domains?.map((domain: DomainConfig) => ({
179181
...domain,
180182
host: domain.host
181183
? processValue(domain.host, variables, schema)
@@ -191,7 +193,9 @@ export function processEnvVars(
191193
variables: Record<string, string>,
192194
schema: Schema,
193195
): Template["envs"] {
194-
return Object.entries(template.config.env).map(
196+
if (!template?.config?.env) return [];
197+
198+
return Object.entries(template?.config?.env).map(
195199
([key, value]: [string, string]) => {
196200
const processedValue = processValue(value, variables, schema);
197201
return `${key}=${processedValue}`;
@@ -207,9 +211,9 @@ export function processMounts(
207211
variables: Record<string, string>,
208212
schema: Schema,
209213
): Template["mounts"] {
210-
if (!template.config.mounts) return [];
214+
if (!template?.config?.mounts) return [];
211215

212-
return template.config.mounts.map((mount: MountConfig) => ({
216+
return template?.config?.mounts?.map((mount: MountConfig) => ({
213217
filePath: processValue(mount.filePath, variables, schema),
214218
content: processValue(mount.content, variables, schema),
215219
}));

0 commit comments

Comments
 (0)