Skip to content

Commit 0a47bf0

Browse files
authored
fix(core): Mark identifier as a required field. (#10946)
* fix(core): Mark `identifier` as a required field. * change tag * inject identifier in tests
1 parent ffa33cd commit 0a47bf0

5 files changed

Lines changed: 28 additions & 6 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri-utils': 'patch:bug'
3+
---
4+
5+
Fixed an issue that made the `identifier` in `tauri.conf.json` optional while it was actually required.

‎crates/tauri-cli/config.schema.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"title": "Config",
44
"description": "The Tauri configuration object.\n It is read from a file where you can define your frontend assets,\n configure the bundler and define a tray icon.\n\n The configuration file is generated by the\n [`tauri init`](https://tauri.app/v1/api/cli#init) command that lives in\n your Tauri application source directory (src-tauri).\n\n Once generated, you may modify it at will to customize your Tauri application.\n\n ## File Formats\n\n By default, the configuration is defined as a JSON file named `tauri.conf.json`.\n\n Tauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively.\n The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`.\n The TOML file name is `Tauri.toml`.\n\n ## Platform-Specific Configuration\n\n In addition to the default configuration file, Tauri can\n read a platform-specific configuration from `tauri.linux.conf.json`,\n `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json`\n (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used),\n which gets merged with the main configuration object.\n\n ## Configuration Structure\n\n The configuration is composed of the following objects:\n\n - [`app`](#appconfig): The Tauri configuration\n - [`build`](#buildconfig): The build configuration\n - [`bundle`](#bundleconfig): The bundle configurations\n - [`plugins`](#pluginconfig): The plugins configuration\n\n Example tauri.config.json file:\n\n ```json\n {\n \"productName\": \"tauri-app\",\n \"version\": \"0.1.0\",\n \"build\": {\n \"beforeBuildCommand\": \"\",\n \"beforeDevCommand\": \"\",\n \"devUrl\": \"../dist\",\n \"frontendDist\": \"../dist\"\n },\n \"app\": {\n \"security\": {\n \"csp\": null\n },\n \"windows\": [\n {\n \"fullscreen\": false,\n \"height\": 600,\n \"resizable\": true,\n \"title\": \"Tauri App\",\n \"width\": 800\n }\n ]\n },\n \"bundle\": {},\n \"plugins\": {}\n }\n ```",
55
"type": "object",
6+
"required": [
7+
"identifier"
8+
],
69
"properties": {
710
"$schema": {
811
"description": "The JSON schema for the Tauri config.",
@@ -27,8 +30,7 @@
2730
]
2831
},
2932
"identifier": {
30-
"description": "The application identifier in reverse domain name notation (e.g. `com.tauri.example`).\n This string must be unique across applications since it is used in system configurations like\n the bundle ID and path to the webview data directory.\n This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-),\n and periods (.).",
31-
"default": "",
33+
"description": "The application identifier in reverse domain name notation (e.g. `com.tauri.example`).\n This string must be unique across applications since it is used in system configurations like\n the bundle ID and path to the webview data directory.\n This string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-),\n and periods (.).",
3234
"type": "string"
3335
},
3436
"app": {

‎crates/tauri-cli/src/migrate/migrations/v1/config.rs‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,20 @@ mod test {
682682
let mut migrated = original.clone();
683683
super::migrate_config(&mut migrated).expect("failed to migrate config");
684684

685+
if original
686+
.get("tauri")
687+
.and_then(|v| v.get("bundle"))
688+
.and_then(|v| v.get("identifier"))
689+
.is_none()
690+
{
691+
if let Some(map) = migrated.as_object_mut() {
692+
map.insert(
693+
"identifier".to_string(),
694+
serde_json::Value::String("com.tauri.test-injected".to_string()),
695+
);
696+
}
697+
}
698+
685699
if let Err(e) = serde_json::from_value::<tauri_utils::config::Config>(migrated.clone()) {
686700
panic!("migrated config is not valid: {e}");
687701
}

‎crates/tauri-schema-generator/schemas/config.schema.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"title": "Config",
44
"description": "The Tauri configuration object.\n It is read from a file where you can define your frontend assets,\n configure the bundler and define a tray icon.\n\n The configuration file is generated by the\n [`tauri init`](https://tauri.app/v1/api/cli#init) command that lives in\n your Tauri application source directory (src-tauri).\n\n Once generated, you may modify it at will to customize your Tauri application.\n\n ## File Formats\n\n By default, the configuration is defined as a JSON file named `tauri.conf.json`.\n\n Tauri also supports JSON5 and TOML files via the `config-json5` and `config-toml` Cargo features, respectively.\n The JSON5 file name must be either `tauri.conf.json` or `tauri.conf.json5`.\n The TOML file name is `Tauri.toml`.\n\n ## Platform-Specific Configuration\n\n In addition to the default configuration file, Tauri can\n read a platform-specific configuration from `tauri.linux.conf.json`,\n `tauri.windows.conf.json`, `tauri.macos.conf.json`, `tauri.android.conf.json` and `tauri.ios.conf.json`\n (or `Tauri.linux.toml`, `Tauri.windows.toml`, `Tauri.macos.toml`, `Tauri.android.toml` and `Tauri.ios.toml` if the `Tauri.toml` format is used),\n which gets merged with the main configuration object.\n\n ## Configuration Structure\n\n The configuration is composed of the following objects:\n\n - [`app`](#appconfig): The Tauri configuration\n - [`build`](#buildconfig): The build configuration\n - [`bundle`](#bundleconfig): The bundle configurations\n - [`plugins`](#pluginconfig): The plugins configuration\n\n Example tauri.config.json file:\n\n ```json\n {\n \"productName\": \"tauri-app\",\n \"version\": \"0.1.0\",\n \"build\": {\n \"beforeBuildCommand\": \"\",\n \"beforeDevCommand\": \"\",\n \"devUrl\": \"../dist\",\n \"frontendDist\": \"../dist\"\n },\n \"app\": {\n \"security\": {\n \"csp\": null\n },\n \"windows\": [\n {\n \"fullscreen\": false,\n \"height\": 600,\n \"resizable\": true,\n \"title\": \"Tauri App\",\n \"width\": 800\n }\n ]\n },\n \"bundle\": {},\n \"plugins\": {}\n }\n ```",
55
"type": "object",
6+
"required": [
7+
"identifier"
8+
],
69
"properties": {
710
"$schema": {
811
"description": "The JSON schema for the Tauri config.",
@@ -27,8 +30,7 @@
2730
]
2831
},
2932
"identifier": {
30-
"description": "The application identifier in reverse domain name notation (e.g. `com.tauri.example`).\n This string must be unique across applications since it is used in system configurations like\n the bundle ID and path to the webview data directory.\n This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-),\n and periods (.).",
31-
"default": "",
33+
"description": "The application identifier in reverse domain name notation (e.g. `com.tauri.example`).\n This string must be unique across applications since it is used in system configurations like\n the bundle ID and path to the webview data directory.\n This string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-),\n and periods (.).",
3234
"type": "string"
3335
},
3436
"app": {

‎crates/tauri-utils/src/config.rs‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2250,9 +2250,8 @@ pub struct Config {
22502250
/// The application identifier in reverse domain name notation (e.g. `com.tauri.example`).
22512251
/// This string must be unique across applications since it is used in system configurations like
22522252
/// the bundle ID and path to the webview data directory.
2253-
/// This string must contain only alphanumeric characters (A–Z, a–z, and 0–9), hyphens (-),
2253+
/// This string must contain only alphanumeric characters (A-Z, a-z, and 0-9), hyphens (-),
22542254
/// and periods (.).
2255-
#[serde(default)]
22562255
pub identifier: String,
22572256
/// The App configuration.
22582257
#[serde(default)]

0 commit comments

Comments
 (0)