Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions plugins/updater/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl Updater {
let mut raw_json: Option<serde_json::Value> = None;
let mut last_error: Option<Error> = None;
for url in &self.endpoints {
// replace {{current_version}}, {{target}} and {{arch}} in the provided URL
// replace {{current_version}}, {{target}}, {{arch}} and {{bundle_type}} in the provided URL
// this is useful if we need to query example
// https://releases.myapp.com/update/{{target}}/{{arch}}/{{current_version}}
// will be translated into ->
Expand All @@ -405,7 +405,7 @@ impl Updater {
let encoded_version = percent_encoding::percent_encode(version, CONTROLS_ADD);
let encoded_version = encoded_version.to_string();

let url: Url = url
let mut url = url
.to_string()
// url::Url automatically url-encodes the path components
.replace("%7B%7Bcurrent_version%7D%7D", &encoded_version)
Expand All @@ -414,8 +414,15 @@ impl Updater {
// but not query parameters
.replace("{{current_version}}", &encoded_version)
.replace("{{target}}", target)
.replace("{{arch}}", self.arch)
.parse()?;
.replace("{{arch}}", self.arch);

if let Some(installer) = installer_for_bundle_type(bundle_type()) {
url = url
.replace("%7B%7Bbundle_type%7D%7D", installer.name())
.replace("{{bundle_type}}", installer.name());
}

Choose a reason for hiding this comment

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

Wouldn't this produce URLs with the placeholder still in it when the installer is None?

Say there's an endpoint like:

https://foo.example/update/my-app/{{target}}-{{arch}}/{{current_version}}?bundle_type={{bundle_type}}

Wouldn't that end up as:

https://foo.example/update/my-app/linux-x86_64/1.2.3?bundle_type={{bundle_type}}

Copy link
Member Author

Choose a reason for hiding this comment

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

yep. any suggestions? Should we replace that with unknown ?

Copy link
Member

Choose a reason for hiding this comment

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

using unknown is fine - though this should only happen in dev mode right? or if you run the target/release/app binary directly

Copy link
Member

Choose a reason for hiding this comment

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

(and i raised this concern before, but we should avoid using unknowns ever - maybe use a default value in that case)

Copy link
Member Author

Choose a reason for hiding this comment

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

using unknown is fine - though this should only happen in dev mode right? or if you run the target/release/app binary directly

Yes, if the dev uses the tauri cli to package the app this should never be unknown. If they're using their own packaging system it'll show unknown (or the last created installer)

Copy link
Member Author

Choose a reason for hiding this comment

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

(and i raised this concern before, but we should avoid using unknowns ever - maybe use a default value in that case)

not sure i get what you mean. any kind of default value we set (assuming default means one of the existing types?) has a high chance to be incorrect.

Choose a reason for hiding this comment

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

yep. any suggestions? Should we replace that with unknown ?

Having pulled the last of my hair out over Helm charts. The reasons this gets tricky is string templating.
To handle nullable values it pushes you down the route of conditional rendering or default values, and it's not fun 😬

So my first suggestion would be, think about alternatives that support nulls easily.
Like a header with these values in JSON.

As for {{bundle_type}}. I do think unknown would make it slightly more useful than say empty string because then you can use it in paths as well as query strings.

Copy link

@beanow-at-crabnebula beanow-at-crabnebula Aug 27, 2025

Choose a reason for hiding this comment

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

Another option could be we we don't support this as a {{bundle_type}} placeholder and instead only support this through the query string. Because we then can assume how query strings work, we can omit it when None.

So it's either:

  • https://foo.example/update/my-app/linux-x86_64/1.2.3
  • https://foo.example/update/my-app/linux-x86_64/1.2.3?bundle_type=appimage


let url: Url = url.parse()?;

log::debug!("checking for updates {url}");

Expand Down
Loading