dotnet/aspnetcore · warning
Unknown action:
Error message
Unknown action:
What it means
Thrown by fetchAndSubmitCredential() in the sample PasskeyUI app.js (line 87) when the submitter's action value is neither 'register' nor 'authenticate'. The function dispatches on the action string to decide whether to create a new credential or get an existing one; any other value falls into the else branch and throws 'Unknown action: <action>'.
Source
Thrown at src/Identity/samples/IdentitySample.PasskeyUI/wwwroot/app.js:87
abortController?.abort();
abortController = new AbortController();
return await navigator.credentials.get({
publicKey: options,
mediation: useConditionalMediation ? 'conditional' : undefined,
signal: abortController.signal,
});
}
async function fetchAndSubmitCredential(action, useConditionalMediation = false) {
try {
const username = new FormData(form).get('username');
let credential;
if (action === 'register') {
credential = await fetchNewCredential(username);
} else if (action === 'authenticate') {
credential = await fetchExistingCredential(username, useConditionalMediation);
} else {
throw new Error('Unknown action: ' + action);
}
var credentialJson = JSON.stringify(credential);
form.addEventListener('formdata', (e) => {
e.formData.append('action', action);
e.formData.append('credential', credentialJson);
}, { once: true });
form.submit();
} catch (error) {
// Ignore abort errors, they are expected when the user cancels the operation.
if (error.name !== 'AbortError') {
statusMessage.textContent = 'Error: ' + error.message;
throw error;
}
}
}
form.addEventListener('submit', (e) => {
if (e.submitter?.name == 'action') {View on GitHub (pinned to 294cab2f9b)
Solutions
- Ensure only the register/authenticate buttons use name="action" with values exactly 'register' and 'authenticate'; give other buttons a different name or type="button".
- If you add new actions, extend the if/else chain in fetchAndSubmitCredential to handle them.
- Verify button values are lowercase and match the dispatch exactly.
- Set formnovalidate/type="button" on non-action submits so they do not trigger the handler.
Example fix
// before <button name="action" value="Save">Save</button> <!-- triggers Unknown action --> // after <button type="button" onclick="...">Save</button> <button name="action" value="register">Register</button> <button name="action" value="authenticate">Sign in</button>
Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_ACTIONS = new Set(['register', 'authenticate']);
function isKnownAction(action: string): boolean {
return KNOWN_ACTIONS.has(action);
} Type guard
type AuthAction = 'register' | 'authenticate';
function isAuthAction(v: unknown): v is AuthAction {
return v === 'register' || v === 'authenticate';
} Prevention
- Only register/authenticate buttons should carry name="action".
- Use type="button" for non-submit buttons in the form.
- Extend the dispatch when adding new actions.
- Keep button values lowercase and exact.
When it happens
Trigger: A submit button inside the auth form has name="action" but a value other than 'register' or 'authenticate' (e.g., a stray submit button like 'Cancel' with name=action). Or the form's submitter.name=='action' check matches an unrelated button.
Common situations: Adding extra submit buttons to the form (Cancel, Reset, secondary actions) that also carry name="action". Copying the sample and renaming button values without updating the dispatch. A button value with different casing ('Register' vs 'register'). A submit triggered by pressing Enter where the submitter is an unexpected button.
Related errors
- Please enter a username.
- EqualTo validator requires a non-empty "other" parameter.
- FileExtensions validator requires a non-empty "extensions" p
- Range validator requires at least one of "min" or "max" para
- regex validator requires a non-empty "pattern" parameter.
AI-assisted analysis of dotnet/aspnetcore@294cab2f9b (2026-08-06).
Data as JSON: /api/errors/8287e5207089242c.
Report an issue: GitHub.