Skip to content

Commit 2165a81

Browse files
committed
enhance: configファイルの読み込み時の設定値検証と検証コマンドを追加
1 parent cb58ff3 commit 2165a81

14 files changed

Lines changed: 790 additions & 176 deletions

File tree

.config/docker_example.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
# Misskey configuration
33
#━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
44

5+
# Validate this configuration before Misskey starts.
6+
# Use "legacy" only temporarily to retain the unvalidated behavior of older versions.
7+
# configValidation: strict
8+
59
# ┌─────┐
610
#───┘ URL └─────────────────────────────────────────────────────
711

.config/example.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@
7373
#
7474
# setupPassword: example_password_please_change_this_or_you_will_get_hacked
7575

76+
# Validate this configuration before Misskey starts.
77+
# Use "legacy" only temporarily to retain the unvalidated behavior of older versions.
78+
# configValidation: strict
79+
7680
# ┌─────┐
7781
#───┘ URL └─────────────────────────────────────────────────────
7882

.github/misskey/test.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,3 @@ redis:
1515
host: 127.0.0.1
1616
port: 56312
1717
id: aidx
18-
19-
proxyRemoteFiles: true

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
## Unreleased
2+
3+
### Note
4+
5+
- configファイルはデフォルトで設定値の検証が行われるようになりました。ソフトウェア更新に際して `pnpm --filter backend validate-config` を実行し、報告された問題を修正してください。
6+
- `signToActivityPubGet``proxyRemoteFiles``disallowExternalApRedirect` がconfigファイルに残っている場合は削除してください。これらの設定はコントロールパネルへ移動済みです。
7+
- 問題をすぐに修正できない場合は、configファイルに `configValidation: legacy` を指定すると、警告を出しつつ従来どおり検証せずに起動できます。
8+
9+
### General
10+
-
11+
12+
### Client
13+
-
14+
15+
### Server
16+
- Enhance: configファイルの読み込み時の設定値検証と検証コマンドを追加
17+
118
## 2026.7.0
219

320
### Note

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"private": true,
2626
"scripts": {
2727
"compile-config": "cd packages/backend && pnpm compile-config",
28+
"validate-config": "cd packages/backend && pnpm validate-config",
2829
"build-pre": "node scripts/build-pre.mjs",
2930
"build-assets": "node ./scripts/build-assets.mjs",
3031
"build": "pnpm build-pre && pnpm -r build && pnpm build-assets",

packages/backend/eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default [
1919
languageOptions: {
2020
parserOptions: {
2121
parser: tsParser,
22-
project: ['./tsconfig.json', './test/tsconfig.json', './test-federation/tsconfig.json'],
22+
project: ['./tsconfig.json', './scripts/tsconfig.json', './test/tsconfig.json', './test-federation/tsconfig.json'],
2323
sourceType: 'module',
2424
tsconfigRootDir: import.meta.dirname,
2525
},

packages/backend/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,16 @@
1515
"cli": "pnpm compile-config && node ./built/cli.js",
1616
"check:connect": "pnpm compile-config && node ./scripts/check_connect.js",
1717
"compile-config": "node ./scripts/compile_config.js",
18+
"validate-config": "pnpm compile-config && tsx ./scripts/validate_config.ts",
1819
"build": "rolldown -c",
1920
"build:unit": "rolldown -c --sourcemap",
2021
"build:e2e": "rolldown -c --e2e",
2122
"build:tsc": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
2223
"watch": "pnpm compile-config && node ./scripts/watch.mjs",
2324
"restart": "pnpm build && pnpm start",
2425
"dev": "pnpm compile-config && rolldown -c --watch",
25-
"typecheck": "tsc --noEmit && tsc -p test --noEmit && tsc -p test-federation --noEmit",
26-
"eslint": "eslint --quiet \"{src,test-federation}/**/*.ts\"",
26+
"typecheck": "tsc --noEmit && tsc -p scripts --noEmit && tsc -p test --noEmit && tsc -p test-federation --noEmit",
27+
"eslint": "eslint --quiet \"{src,scripts,test-federation}/**/*.ts\"",
2728
"lint": "pnpm typecheck && pnpm eslint",
2829
"test": "pnpm build:unit && cross-env NODE_ENV=test pnpm compile-config && vitest --config vitest.config.unit.ts",
2930
"test:e2e": "pnpm build:e2e && cross-env NODE_ENV=test pnpm compile-config && vitest --config vitest.config.e2e.ts",
@@ -148,8 +149,10 @@
148149
"tinycolor2": "1.6.0",
149150
"tmp": "0.2.7",
150151
"tsc-alias": "1.9.0",
152+
"tsx": "4.23.1",
151153
"typeorm": "1.1.0",
152154
"ulid": "3.0.2",
155+
"valibot": "1.4.2",
153156
"vary": "1.1.2",
154157
"web-push": "3.6.7",
155158
"ws": "8.21.0",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"compilerOptions": {
4+
"noEmit": true,
5+
"rootDir": ".."
6+
},
7+
"include": [
8+
"./validate_config.ts"
9+
]
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* SPDX-FileCopyrightText: syuilo and misskey-project
3+
* SPDX-License-Identifier: AGPL-3.0-only
4+
*/
5+
6+
import { loadConfig } from '../src/config.js';
7+
8+
try {
9+
loadConfig({ forceConfigValidation: true });
10+
console.log('Configuration is valid ✓');
11+
} catch (error) {
12+
console.error(error instanceof Error ? error.message : 'Configuration validation failed');
13+
process.exitCode = 1;
14+
}

packages/backend/src/boot/master.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,20 @@ function showNodejsVersion(): void {
152152
/** 設定を読み込み、成功時に後続のログ出力形式を適用します。 */
153153
function loadConfigBoot(): Config {
154154
const configLogger = bootLogger.createSubLogger('config');
155+
const configWarnings: string[] = [];
155156
let config;
156157

157158
try {
158-
config = loadConfig();
159+
config = loadConfig({
160+
onWarning: warning => configWarnings.push(warning),
161+
});
159162
configureLogging(config.logging);
163+
for (const warning of configWarnings) {
164+
configLogger.warn({
165+
message: warning,
166+
eventName: 'config.validation.disabled',
167+
});
168+
}
160169
} catch (exception) {
161170
if (typeof exception === 'string') {
162171
configLogger.error(exception);

0 commit comments

Comments
 (0)