Skip to content

Commit 2f9502d

Browse files
committed
turn confog validation off
1 parent 8f2851d commit 2f9502d

File tree

6 files changed

+48
-29
lines changed

6 files changed

+48
-29
lines changed

config.schema.json

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717
"type": "boolean"
1818
},
1919
"time_format": {
20-
"type": ["integer", "string"]
20+
"oneOf": [
21+
{ "type": "string", "enum": ["12", "24"] },
22+
{ "type": "integer", "enum": [12, 24] }
23+
],
24+
"examples": ["12", "24"]
2125
},
2226
"show_date": {
2327
"type": "boolean"
@@ -47,7 +51,8 @@
4751
"type": ["string", "array"],
4852
"items": {
4953
"type": "string"
50-
}
54+
},
55+
"uniqueItems": true
5156
},
5257
"require_all_people": {
5358
"type": "boolean"
@@ -56,13 +61,15 @@
5661
"type": ["string", "array"],
5762
"items": {
5863
"type": "string"
59-
}
64+
},
65+
"uniqueItems": true
6066
},
6167
"albums": {
6268
"type": ["string", "array"],
6369
"items": {
6470
"type": "string"
65-
}
71+
},
72+
"uniqueItems": true
6673
},
6774
"album_video": {
6875
"type": "boolean"
@@ -74,19 +81,22 @@
7481
"type": ["string", "array"],
7582
"items": {
7683
"type": "string"
77-
}
84+
},
85+
"uniqueItems": true
7886
},
7987
"dates": {
8088
"type": ["string", "array"],
8189
"items": {
8290
"type": "string"
83-
}
91+
},
92+
"uniqueItems": true
8493
},
8594
"tags": {
8695
"type": ["string", "array"],
8796
"items": {
8897
"type": "string"
89-
}
98+
},
99+
"uniqueItems": true
90100
},
91101
"memories": {
92102
"type": "boolean"
@@ -200,7 +210,11 @@
200210
"type": "boolean"
201211
},
202212
"image_time_format": {
203-
"type": ["integer", "string"]
213+
"oneOf": [
214+
{ "type": "string", "enum": ["12", "24"] },
215+
{ "type": "integer", "enum": [12, 24] }
216+
],
217+
"examples": ["12", "24"]
204218
},
205219
"show_image_date": {
206220
"type": "boolean"
@@ -224,7 +238,8 @@
224238
"type": ["string", "array"],
225239
"items": {
226240
"type": "string"
227-
}
241+
},
242+
"uniqueItems": true
228243
},
229244
"show_image_id": {
230245
"type": "boolean"
@@ -242,13 +257,15 @@
242257
"type": ["string", "array"],
243258
"items": {
244259
"type": "string"
245-
}
260+
},
261+
"uniqueItems": true
246262
},
247263
"hide_button_action": {
248264
"type": ["string", "array"],
249265
"items": {
250266
"type": "string"
251-
}
267+
},
268+
"uniqueItems": true
252269
},
253270
"weather": {
254271
"type": "array",
@@ -307,13 +324,15 @@
307324
"type": "array",
308325
"items": {
309326
"type": "string"
310-
}
327+
},
328+
"uniqueItems": true
311329
},
312330
"iframe": {
313331
"type": ["string", "array"],
314332
"items": {
315333
"type": "string"
316-
}
334+
},
335+
"uniqueItems": true
317336
},
318337
"immich_users_api_keys": {
319338
"type": "object",
@@ -329,7 +348,8 @@
329348
"type": ["string", "array"],
330349
"items": {
331350
"type": "string"
332-
}
351+
},
352+
"uniqueItems": true
333353
},
334354
"show_user": {
335355
"type": "boolean"
@@ -373,9 +393,9 @@
373393
},
374394
"config_validation_level": {
375395
"type": "string",
376-
"enum": ["warning", "error"],
396+
"enum": ["warning", "error", "off"],
377397
"default": "error",
378-
"description": "Controls how invalid configuration is handled. 'warning' logs a warning and continues; 'error' treats invalid configuration as fatal."
398+
"description": "Controls how invalid configuration is handled. 'warning' logs a warning and continues; 'error' treats invalid configuration as fatal; 'off' disables validation checks."
379399
},
380400
"port": {
381401
"type": "integer"

internal/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ type Config struct {
290290
// WeatherLocations A list of locations to fetch and display weather data from. Each location
291291
WeatherLocations []WeatherLocation `json:"weather" yaml:"weather" mapstructure:"weather" default:"[]"`
292292

293-
Iframe []string `json:"iframe" yaml:"iframe" mapstructure:"iframe" query:"iframe" form:"iframe" default:""`
293+
Iframe []string `json:"iframe" yaml:"iframe" mapstructure:"iframe" query:"iframe" form:"iframe" default:"[]"`
294294

295295
// Webhooks defines a list of webhook endpoints and their associated events that should trigger notifications.
296296
Webhooks Webhooks `json:"webhooks" yaml:"webhooks" mapstructure:"webhooks" default:"[]"`
@@ -531,7 +531,7 @@ func (c *Config) Load() error {
531531
}
532532
} else {
533533
level := strings.ToLower(strings.TrimSpace(c.V.GetString("kiosk.config_validation_level")))
534-
if level != kiosk.ConfigValidationWarning && level != kiosk.ConfigValidationError {
534+
if level != kiosk.ConfigValidationWarning && level != kiosk.ConfigValidationError && level != kiosk.ConfigValidationOff {
535535
level = kiosk.ConfigValidationError
536536
}
537537

internal/config/config_validation.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package config
22

33
import (
4-
"encoding/json"
54
"fmt"
65
"net/url"
76
"os"
@@ -11,6 +10,7 @@ import (
1110
"strings"
1211

1312
"github.com/charmbracelet/log"
13+
"github.com/damongolding/immich-kiosk/internal/kiosk"
1414
"github.com/xeipuuv/gojsonschema"
1515
)
1616

@@ -363,6 +363,10 @@ func (c *Config) checkOffline() {
363363
}
364364

365365
func checkSchema(config map[string]any, level string) bool {
366+
if strings.EqualFold(level, kiosk.ConfigValidationOff) {
367+
log.Info("Config validation disabled")
368+
return true
369+
}
366370

367371
if !IsSchemaLoaded() {
368372
log.Warn("Schema not loaded, skipping validation")
@@ -376,15 +380,9 @@ func checkSchema(config map[string]any, level string) bool {
376380
}
377381
}
378382

379-
jsonData, err := json.Marshal(typed)
380-
if err != nil {
381-
log.Error("Schema validation setup failed: marshal", "err", err)
382-
return false
383-
}
384-
385383
// Load JSON Schema from file
386384
schemaLoader := gojsonschema.NewStringLoader(SchemaJSON)
387-
docLoader := gojsonschema.NewBytesLoader(jsonData)
385+
docLoader := gojsonschema.NewGoLoader(typed)
388386

389387
// Validate
390388
result, err := gojsonschema.Validate(schemaLoader, docLoader)

internal/demo/demo.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func ValidateToken(ctx context.Context, token string) bool {
6565

6666
resp, err := httpClient.Do(req)
6767
if err != nil {
68-
log.Error("ValidateToken: sendingrequest", "err", err)
68+
log.Error("ValidateToken: sending request", "err", err)
6969
return false
7070
}
7171
defer resp.Body.Close()
@@ -150,7 +150,7 @@ func Login(ctx context.Context, refresh bool) (string, error) {
150150
// Read response
151151
body, err := io.ReadAll(resp.Body)
152152
if err != nil {
153-
log.Error("DemoLogin: reading request", "err", err)
153+
log.Error("DemoLogin: reading response", "err", err)
154154
return "", err
155155
}
156156

internal/kiosk/kiosk.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ type Source string
55
const (
66
ConfigValidationWarning string = "warning"
77
ConfigValidationError string = "error"
8+
ConfigValidationOff string = "off"
89

910
AlbumKeywordAll string = "all"
1011
AlbumKeywordOwned string = "owned"

taskfile.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: "3"
22
env:
3-
VERSION: 0.23.1
3+
VERSION: 0.23.2-beta.1
44

55
includes:
66
frontend:

0 commit comments

Comments
 (0)