Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: config.json の validation 失敗時にわかりやすいログを出すように #1222

Merged
merged 5 commits into from
Feb 23, 2023

Conversation

raa0121
Copy link
Contributor

@raa0121 raa0121 commented Feb 22, 2023

内容

config.json の validation に失敗した時にエラーが出るが、わかりにくいため、別途ログを出すようにしました。
Discord の経緯 https://discord.com/channels/879570910208733277/893889888208977960/1077566801602424963
折りたたみにエラー例を追加しておきました。

Error: Config schema violation: `defaultStyleIds/0/engineId` must match format "uuid"; `defaultStyleIds/0/engineId` must be equal to constant; `defaultStyleIds/0/engineId` must match a schema in anyOf; `defaultStyleIds/1/engineId` must match format "uuid"; `defaultStyleIds/
1/engineId` must be equal to constant; `defaultStyleIds/1/engineId` must match a schema in anyOf; `defaultStyleIds/2/engineId` must match format "uuid"; `defaultStyleIds/2/engineId` must be equal to constant; `defaultStyleIds/2/engineId` must match a schema in anyOf; `defau
ltStyleIds/3/engineId` must match format "uuid"; `defaultStyleIds/3/engineId` must be equal to constant; `defaultStyleIds/3/engineId` must match a schema in anyOf; `defaultStyleIds/4/engineId` must match format "uuid"; `defaultStyleIds/4/engineId` must be equal to constant;
 `defaultStyleIds/4/engineId` must match a schema in anyOf; `defaultStyleIds/5/engineId` must match format "uuid"; `defaultStyleIds/5/engineId` must be equal to constant; `defaultStyleIds/5/engineId` must match a schema in anyOf; `defaultStyleIds/6/engineId` must match form
at "uuid"; `defaultStyleIds/6/engineId` must be equal to constant; `defaultStyleIds/6/engineId` must match a schema in anyOf; `defaultStyleIds/7/engineId` must match format "uuid"; `defaultStyleIds/7/engineId` must be equal to constant; `defaultStyleIds/7/engineId` must mat
ch a schema in anyOf; `defaultStyleIds/8/engineId` must match format "uuid"; `defaultStyleIds/8/engineId` must be equal to constant; `defaultStyleIds/8/engineId` must match a schema in anyOf; `defaultStyleIds/9/engineId` must match format "uuid"; `defaultStyleIds/9/engineId
` must be equal to constant; `defaultStyleIds/9/engineId` must match a schema in anyOf; `defaultStyleIds/10/engineId` must match format "uuid"; `defaultStyleIds/10/engineId` must be equal to constant; `defaultStyleIds/10/engineId` must match a schema in anyOf; `defaultStyle
Ids/11/engineId` must match format "uuid"; `defaultStyleIds/11/engineId` must be equal to constant; `defaultStyleIds/11/engineId` must match a schema in anyOf; `defaultStyleIds/12/engineId` must match format "uuid"; `defaultStyleIds/12/engineId` must be equal to constant; `
defaultStyleIds/12/engineId` must match a schema in anyOf; `defaultStyleIds/13/engineId` must match format "uuid"; `defaultStyleIds/13/engineId` must be equal to constant; `defaultStyleIds/13/engineId` must match a schema in anyOf; `defaultStyleIds/14/engineId` must match f
ormat "uuid"; `defaultStyleIds/14/engineId` must be equal to constant; `defaultStyleIds/14/engineId` must match a schema in anyOf; `defaultStyleIds/15/engineId` must match format "uuid"; `defaultStyleIds/15/engineId` must be equal to constant; `defaultStyleIds/15/engineId` 
must match a schema in anyOf; `defaultStyleIds/16/engineId` must match format "uuid"; `defaultStyleIds/16/engineId` must be equal to constant; `defaultStyleIds/16/engineId` must match a schema in anyOf; `defaultStyleIds/17/engineId` must match format "uuid"; `defaultStyleId
s/17/engineId` must be equal to constant; `defaultStyleIds/17/engineId` must match a schema in anyOf; `defaultStyleIds/18/engineId` must match format "uuid"; `defaultStyleIds/18/engineId` must be equal to constant; `defaultStyleIds/18/engineId` must match a schema in anyOf
    at wL._validate (C:\msys64\home\raa0121\develop\voicevox\dist\background.js:18:37971)
    at get store [as store] (C:\msys64\home\raa0121\develop\voicevox\dist\background.js:18:36709)
    at new G (C:\msys64\home\raa0121\develop\voicevox\dist\background.js:18:34631)
    at new wL (C:\msys64\home\raa0121\develop\voicevox\dist\background.js:18:40682)
    at Object.<anonymous> (C:\msys64\home\raa0121\develop\voicevox\dist\background.js:539:1165)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1175:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)
    at c._load (node:electron/js2c/asar_bundle:5:13343)
    at loadApplicationPackage (C:\msys64\home\raa0121\develop\voicevox\node_modules\electron\dist\resources\default_app.asar\main.js:121:16)
    at Object.<anonymous> (C:\msys64\home\raa0121\develop\voicevox\node_modules\electron\dist\resources\default_app.asar\main.js:233:9)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1175:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
    at Module._load (node:internal/modules/cjs/loader:829:12)

@raa0121 raa0121 requested a review from a team as a code owner February 22, 2023 02:22
@raa0121 raa0121 requested review from Hiroshiba and removed request for a team February 22, 2023 02:22
Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

PRありがとうございます!!

src/background.ts Show resolved Hide resolved
src/background.ts Outdated Show resolved Hide resolved
src/background.ts Outdated Show resolved Hide resolved
Copy link
Member

@Hiroshiba Hiroshiba left a comment

Choose a reason for hiding this comment

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

LGTM!!

ありがとうございます、結構いろんな方が詰まるポイントだったので助かります!!
一点だけコメントしてみました!

log.error(
`設定ファイルの読み込みに失敗しました。${app.getPath(
"userData"
)}にあるconfig.json の名前を変えることで解決することがあります(ただし設定がすべてリセットされます)。`
Copy link
Member

Choose a reason for hiding this comment

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

フォルダを開くボタン(またはリネームして再起動ボタン)を追加してあげると親切なような気がしました。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

electron 自体が起動する前なので、ウィンドウを出すのも厳しい気がします。
検証はしてみますが。

Copy link
Member

@sevenc-nanashi sevenc-nanashi Feb 22, 2023

Choose a reason for hiding this comment

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

https://www.electronjs.org/ja/docs/latest/api/dialog#dialogshowerrorboxtitle-content

app モジュールで ready イベントが発生する前でも、このAPIは安全に呼び出すことができます。これは、起動の初期段階でのエラーを報告するのによく使用されます。

これが使えそう?
選択はできませんが

Copy link
Member

@Hiroshiba Hiroshiba Feb 22, 2023

Choose a reason for hiding this comment

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

あ、僕もちょっと思いました。ダイアログにしたら良さそうだなと。
たしかにdialog.showErrorBox使えそうですね!!
他にもdialog.showErrorBox使ってる所あるので参考になるかもです。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

dialog.showErrorBox を出した後に、shell.openPathshell.showItemInFolder でフォルダを開けないか試してみましたが、流石に ready 前なので動かなそうでした。
ひとまず dialog.showErrorBox にしますね。

Copy link
Member

@Hiroshiba Hiroshiba Feb 23, 2023

Choose a reason for hiding this comment

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

個人的には依存増やしてまで(メンテコスト増やしてまで)ディレクトリ開く機能を付けるのはしなくても良いかも?と思いました。
まあ、@raa0121 さんのやりたいように…!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

私も同じく、依存を増やすほどじゃないかなと思いました。

Copy link
Member

Choose a reason for hiding this comment

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

どうでしょう? @sevenc-nanashi
まあ良いかと思える感じであればapproveいただけると!!

Copy link
Member

@sevenc-nanashi sevenc-nanashi Feb 23, 2023

Choose a reason for hiding this comment

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

依存を増やしたくない、なるほど(そういう考えをしたことが無かった)

まぁ大丈夫だと思います。
(ボタンを提案した理由はファイルパスを手打ちしなくてもいいから。エラーダイアログはコピペが出来ないので)

Copy link
Member

Choose a reason for hiding this comment

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

手打ちが面倒なのはめちゃわかります。
そもそも開発者向けには、やはりconfig.jsonをクリアする方法を提供するのが一番いいかなと思いました。
(そしてそれは結構実装が大変。electron-storeの仕様が。。。 😇 )

src/background.ts Show resolved Hide resolved
Copy link
Member

@sevenc-nanashi sevenc-nanashi left a comment

Choose a reason for hiding this comment

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

🚀

@Hiroshiba
Copy link
Member

レビューありです!! マージします!!

@Hiroshiba Hiroshiba merged commit eb11467 into VOICEVOX:main Feb 23, 2023
@raa0121 raa0121 deleted the fix-config-json-validation branch February 24, 2023 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants