linera-io/linera-protocol · error
Invalid application ID
Error message
Invalid application ID
What it means
While building a ResourceControlPolicy in the linera CLI (free_application_ids field), each --free-application-ids string is parsed with ApplicationId's FromStr and collected into a BTreeSet. The expect panics when any supplied string is not a valid canonical ApplicationId, aborting the policy/command before anything is written.
Source
Thrown at linera-service/src/cli/main.rs:719
existing_policy.maximum_oracle_response_bytes,
),
maximum_http_response_bytes: maximum_http_response_bytes
.unwrap_or(existing_policy.maximum_http_response_bytes),
http_request_timeout_ms: http_request_timeout_ms
.unwrap_or(existing_policy.http_request_timeout_ms),
http_request_allow_list: http_request_allow_list
.map(BTreeSet::from_iter)
.unwrap_or(existing_policy.http_request_allow_list),
free_application_ids: free_application_ids
.map(|ids| {
ids.into_iter().map(|s| s.parse()).collect::<Result<
BTreeSet<_>,
_,
>>(
)
})
.transpose()
.expect("Invalid application ID")
.unwrap_or(existing_policy.free_application_ids),
flags: flags
.map(|values| {
values
.into_iter()
.map(|s| s.parse())
.collect::<Result<BTreeSet<_>, _>>()
})
.transpose()
.expect("Invalid protocol flag")
.unwrap_or(existing_policy.flags),
};
info!("{policy}");
if committee.policy() == &policy {
return Ok(ClientOutcome::Committed(None));
}
}
_ => unreachable!(),View on GitHub (pinned to 6c226ddcb3)
Solutions
- Copy the exact full application ID string as printed by `linera query-application` (the `application_id` field, plain hex, no 0x, no quotes)
- Extract it programmatically instead of by hand: jq -r '.application_id' from JSON output, or use the value returned by publish
- Pre-validate each ID in your script before invoking the CLI (parse/regex check for full-length hex)
- If parsing still fails, confirm you are on the same network/genesis the application was published to
Example fix
# before linera ... --free-application-ids 0xe5ab00... # 0x prefix + truncated # after APP_ID=$(linera query-application --abi-... | jq -r '.application_id') linera ... --free-application-ids "$APP_ID"
Defensive patterns
Strategy: validation
Validate before calling
# Validate the ID shape before invoking the CLI.
APP_ID='...'
if ! [[ "$APP_ID" =~ ^[0-9a-f]{40,}$ ]]; then echo "not a canonical application id" >&2; exit 1; fi Prevention
- Extract IDs with jq from machine-readable output instead of copy-paste
- Keep a single source of truth (env file) for published application IDs per network
- Never mix IDs between networks/geneses; tag them in config
When it happens
Trigger: Passing --free-application-ids with a value that fails ApplicationId::from_str: truncated hex, a bytecode ID or blob hash instead of an application ID, a value with '0x' prefix, whitespace, or a JSON-quoted string.
Common situations: Copy-pasting the wrong identifier from `linera query-application` output (which prints bytecode_id, publisher, and application_id separately); hand-truncating the long hex string in scripts; passing IDs from a different network/genesis whose format is not parseable.
Related errors
- expected whitespace after 'query' keyword
- expected an operation name after 'query', e.g. 'query MyQuer
- The input has not matched: {input}
- Invalid protocol flag
- Invalid parsing of GenericApplicationId
AI-assisted analysis of linera-io/linera-protocol@6c226ddcb3 (2026-08-22).
Data as JSON: /api/errors/a8626642d7475643.
Report an issue: GitHub.