dotnet/orleans · error · InvalidOperationException
You have already created 5 polls, which is enough for anybod
Error message
You have already created 5 polls, which is enough for anybody.
What it means
Thrown by Voting UserAgentGrain.CreatePoll when the user has already created 5 polls (_myPolls.Count >= 5). It enforces a per-user quota, a deliberate limit (the message is a deliberate Quora-style joke 'enough for anybody').
Source
Thrown at samples/Voting/Grains/UserAgentGrain.cs:48
// Get a reference to the poll grain
var pollGrain = _grainFactory.GetGrain<IPollGrain>(pollId);
// Get the current poll results
var results = await pollGrain.GetCurrentResults();
// Return the results as well as whether we've voted in the poll or not
return (Results: results, Voted: _votedPolls.Contains(pollId));
}
public async Task<string> CreatePoll(PollState initialState)
{
Throttle();
// Limit the number of polls any one user can make
if (_myPolls.Count >= 5)
{
throw new InvalidOperationException("You have already created 5 polls, which is enough for anybody.");
}
// Generate a new id and get a reference to the PollGrain with that id
var pollId = Guid.NewGuid().ToString("N")[..6];
var pollGrain = _grainFactory.GetGrain<IPollGrain>(pollId);
// Create the poll. We could avoid collisions here by making this return an error if a poll
// with that id already exists.
await pollGrain.CreatePoll(initialState);
_myPolls.Add(pollId);
return pollId;
}
public async Task<PollState> AddVote(string pollId, int optionId)
{
Throttle();
View on GitHub (pinned to fca799fa70)
Solutions
- Use a different user grain key (new user) once the quota is reached.
- Raise or remove the `>= 5` cap if your fork needs more polls.
- Catch InvalidOperationException and tell the user they have reached the limit.
Example fix
// before
if (_myPolls.Count >= 5) throw new InvalidOperationException("...");
// after: configurable quota
if (_myPolls.Count >= MaxPollsPerUser) throw new InvalidOperationException("..."); Defensive patterns
Strategy: try-catch
Validate before calling
// Track polls created per user on the client and stop before the limit
if (createdPolls >= 5) { ShowMessage("Poll limit reached."); return; } Type guard
null
Try / catch
try { await user.CreatePoll(state); }
catch (InvalidOperationException ex) when (ex.Message.Contains("5 polls"))
{ /* inform user they hit the quota */ } Prevention
- Treat five polls per user as a hard cap; use a new user id beyond it.
- Raise the constant in your fork if more polls are needed.
- Catch InvalidOperationException to surface the limit gracefully.
When it happens
Trigger: A user (one grain key per user) calls CreatePoll a sixth time; _myPolls is a per-activation set that grows by one each successful create.
Common situations: A test loop creating many polls under the same user id; a UI bug that double-submits; legitimately needing more than five polls.
Related errors
- Invalid option {optionId}
- You have already voted in that poll!
- The requested vote option was not found.
- Missing value for {name}.
- Can't join game once its over
AI-assisted analysis of dotnet/orleans@fca799fa70 (2026-08-13).
Data as JSON: /api/errors/aac6e5cc7c415424.
Report an issue: GitHub.