dotnet/orleans · error · ArgumentException
Input is not in a valid format: Encountered unsupported esca
Error message
Input is not in a valid format: Encountered unsupported escape sequence
What it means
Thrown by CosmosIdSanitizer when decoding a previously-sanitized identifier: an escape character is followed by a replacement character that is not in the known ReplacementCharacters set. This means the input is not a string produced by this sanitizer.
Source
Thrown at src/Azure/Shared/Cosmos/CosmosIdSanitizer.cs:85
}
if (count == 0)
{
return input;
}
return string.Create(input.Length - count, input, static (output, input) =>
{
var i = 0;
var isEscaped = false;
foreach (var c in input)
{
if (isEscaped)
{
var charId = ReplacementCharacters.IndexOf(c);
if (charId < 0)
{
throw new ArgumentException($"Input is not in a valid format: Encountered unsupported escape sequence");
}
output[i++] = SanitizedCharacters[charId];
isEscaped = false;
}
else if (c == EscapeChar)
{
isEscaped = true;
}
else
{
output[i++] = c;
}
}
});
}
}View on GitHub (pinned to fca799fa70)
Solutions
- Only pass ids that were produced by the sanitizer's encode path to the decode path.
- If the id is user-supplied, run it through the encode (sanitize) direction first.
- Avoid constructing ids containing the escape character manually.
Example fix
// before var raw = "grain|weird"; // contains sanitizer escape-like sequence sanitizer.Decode(raw); // after var encoded = sanitizer.Encode(userInput); // round-trip safe sanitizer.Decode(encoded);
Defensive patterns
Strategy: validation
Validate before calling
var encoded = sanitizer.Encode(input); // only ever decode encoded output var decoded = sanitizer.Decode(encoded);
Type guard
static bool LooksSanitized(string? s) => s is not null && s.IndexOf(EscapeChar) >= 0;
Prevention
- Round-trip ids through Encode before Decode.
- Never hand-author ids containing the sanitizer escape character.
When it happens
Trigger: Calling the sanitizer's decode path on a hand-authored or externally-produced id that contains the escape char followed by an unexpected character.
Common situations: Manually constructing grain ids or Cosmos partition keys that resemble sanitized ids but were never actually sanitized; mixing sanitized and raw ids; a schema change in the sanitizer's escape set across versions.
Related errors
- Configuration for Azure Cosmos DB provider {_name} is invali
- Configuration for Azure Cosmos DB provider {_name} is invali
- Configuration for Azure Cosmos DB provider {_name} is invali
- No credentials specified. Use the AzureBlobStorageOptions.Co
- Configuration for AzureBlobStorageOptions {name} is invalid.
AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13).
Data as JSON: /api/errors/ee16a4de50ea5282.
Report an issue: GitHub.