Skip to main content

validate_extension_version

Function validate_extension_version 

Source
pub fn validate_extension_version(version: &str) -> Result<(), ExtensionError>
Expand description

Validates an extension version string for a community-extension description.yml.

This is deliberately permissive. DuckDB’s community-extension documentation specifies no version format — it says only that the descriptor carries “the version of the extension” and points at existing extensions as examples. In the duckdb/community-extensions repository at commit 5ae7df8, 334 of the 346 description.yml files declare a version, and 42 of those are a date-based build id — 41 YYYYMMDDNN like 2025120401, one YYYYMMDD — which is neither semver nor a git hash (one more is the four-part 0.1.5.5). Rejecting those would tell one published extension in eight that its descriptor is invalid.

So this checks only what would actually break: an empty version, one longer than 64 characters, or one containing anything outside [A-Za-z0-9._+-] — whitespace, path separators and control characters, all of which would corrupt the metadata the version ends up in.

Use classify_extension_version when you want DuckDB’s three-tier stability scheme, which is documented and is strict.

§Errors

Returns ExtensionError if the version is empty, too long, or contains a character outside the allowed set.

§Example

use quack_rs::validate::validate_extension_version;

assert!(validate_extension_version("1.0.0").is_ok());
assert!(validate_extension_version("0.1.0").is_ok());
assert!(validate_extension_version("690bfc5").is_ok());
// A date-based build id, as 42 published community extensions use.
assert!(validate_extension_version("2025120401").is_ok());

assert!(validate_extension_version("").is_err());
assert!(validate_extension_version("1.0.0 beta").is_err()); // whitespace
assert!(validate_extension_version("../etc/passwd").is_err()); // path separator