microsoft/FASTER · error · FasterException
Cannot use empty string as session name
Error message
Cannot use empty string as session name
What it means
FASTERClientSession.InternalNewSession treats an empty string session name as invalid: null means 'auto-generate a name', so "" is ambiguous and would collide with FASTER's naming/recovery conventions. It throws FasterException instead of registering a session with an empty name.
Solutions
- Pass null instead of "" to let FASTER auto-generate a unique session name.
- Provide a non-empty descriptive name, e.g. $"session-{Guid.NewGuid()}" or a business identifier.
- Validate sessionName with string.IsNullOrWhiteSpace before calling and substitute a default.
Example fix
// before
var session = fasterKV.NewSession(functions, sessionName: ""); // throws
// after
var session = fasterKV.NewSession(functions, sessionName: null); // auto-generated name
// or
var name = string.IsNullOrWhiteSpace(configuredName) ? $"session-{Guid.NewGuid()}" : configuredName; Defensive patterns
Strategy: validation
Validate before calling
string sessionName = string.IsNullOrEmpty(configuredName) ? null : configuredName; // null = auto-generate var session = fasterKV.NewSession(functions, sessionName);
Type guard
string NormalizeSessionName(string name) => string.IsNullOrWhiteSpace(name) ? null : name;
Try / catch
try
{
var session = clientSession.NewSession<MyFunctions>(sessionName);
}
catch (FasterException ex) when (ex.Message.Contains("empty string"))
{
var session = clientSession.NewSession<MyFunctions>(); // auto-generated name
} Prevention
- Validate config-derived session names with string.IsNullOrWhiteSpace at load time.
- Treat null (not "") as the sentinel for 'auto-generate name' in your codebase.
- Sanitize interpolated names so missing components never yield "".
When it happens
Trigger: Passing sessionName: "" to the session-creating API that funnels into InternalNewSession (e.g. NewSession with an explicitly empty string name).
Common situations: Session names read from config/environment that default to empty strings; string interpolation producing "" when an ID part is missing.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Allocator with sector size
- Async operations not supported over protected epoch
- AsyncReadRecordObjectsToMemory invalid for…
- Attempt to lock with unknown LockType
- BlittableAllocator memory pages are sector aligned - use…
AI-assisted analysis of microsoft/FASTER@321d872eab (2026-09-15).
Data as JSON: /api/errors/827aef3dd179059e.
Report an issue: GitHub.
Appendix: source
Thrown at cs/src/core/ClientSession/FASTERClientSession.cs:167
/// <param name="sessionName">Name of session (optional)</param>
/// <param name="sessionVariableLengthStructSettings">Session-specific variable-length struct settings</param>
/// <param name="readCopyOptions"><see cref="ReadCopyOptions"/> for this session; override those specified at FasterKV level, and may be overridden on individual Read operations</param>
/// <returns>Session instance</returns>
internal ClientSession<Key, Value, Input, Output, Context, Functions> NewSession<Input, Output, Context, Functions>(Functions functions, string sessionName = null,
SessionVariableLengthStructSettings<Value, Input> sessionVariableLengthStructSettings = null, ReadCopyOptions readCopyOptions = default)
where Functions : IFunctions<Key, Value, Input, Output, Context>
=> InternalNewSession<Input, Output, Context, Functions, ClientSession<Key, Value, Input, Output, Context, Functions>>(functions, sessionName,
ctx => new ClientSession<Key, Value, Input, Output, Context, Functions>(this, ctx, functions, sessionVariableLengthStructSettings), readCopyOptions);
private TSession InternalNewSession<Input, Output, Context, Functions, TSession>(Functions functions, string sessionName,
Func<FasterExecutionContext<Input, Output, Context>, TSession> sessionCreator, ReadCopyOptions readCopyOptions)
where TSession : IClientSession
{
if (functions == null)
throw new ArgumentNullException(nameof(functions));
if (sessionName == "")
throw new FasterException("Cannot use empty string as session name");
if (sessionName != null && _recoveredSessionNameMap != null && _recoveredSessionNameMap.ContainsKey(sessionName))
throw new FasterException($"Session named {sessionName} already exists in recovery info, use RecoverSession to resume it");
int sessionID = Interlocked.Increment(ref maxSessionID);
var ctx = new FasterExecutionContext<Input, Output, Context>();
InitContext(ctx, sessionID, sessionName);
ctx.MergeReadCopyOptions(this.ReadCopyOptions, readCopyOptions);
var prevCtx = new FasterExecutionContext<Input, Output, Context>();
InitContext(prevCtx, sessionID, sessionName);
prevCtx.version--;
prevCtx.ReadCopyOptions = ctx.ReadCopyOptions;
ctx.prevCtx = prevCtx;
if (_activeSessions == null)
Interlocked.CompareExchange(ref _activeSessions, new Dictionary<int, SessionInfo>(), null);
View on GitHub (pinned to 321d872eab)