gildas-lormeau/SingleFile · error · Error
Cannot identify the extension requesting SingleFile capture
Error message
Cannot identify the extension requesting SingleFile capture
What it means
requestPermission in external-capture-permissions.js validates that the incoming message originates from a browser extension with a sender.id. If sender is missing or has no id, it throws this error because the caller's extension cannot be identified or checked against the allow/deny permission lists.
Source
Thrown at src/core/bg/external-capture-permissions.js:50
let requestId = 0;
export {
onMessage,
requestPermission
};
if (browser.tabs.onRemoved) {
browser.tabs.onRemoved.addListener(tabId => {
Array.from(pendingRequests.values())
.filter(request => request.tabId == tabId)
.forEach(request => resolveRequest(request, false));
});
}
async function requestPermission(sender, message = {}) {
const extensionId = sender && sender.id;
if (!extensionId) {
throw new Error("Cannot identify the extension requesting SingleFile capture");
}
const permissions = await config.getExternalCapturePermissions();
if (permissions.allowedExtensionIds.includes(extensionId)) {
return true;
}
if (permissions.deniedExtensionIds.includes(extensionId)) {
return false;
}
const { request, created } = getOrCreatePendingRequest(extensionId, sender, message);
if (created) {
await openOptionsPage(request);
}
return request.promise;
}
async function onMessage(message, sender) {
if (!isOptionsPageSender(sender)) {
throw new Error("Unauthorized sender");View on GitHub (pinned to 517fb7c5cf)
Solutions
- Ensure the caller is a real extension and calls chrome.runtime.sendMessage(EXTENSION_ID, ...) so sender.id is populated
- Update the integrating extension to the latest version that sends proper sender metadata
- Verify the message route is onMessageExternal (external messages) not an internal handler
- If you control the caller, pass a valid sender object when invoking requestPermission
Example fix
// before chrome.runtime.sendMessage(msg); // from a page, no sender.id // after chrome.runtime.sendMessage(SINGLEFILE_EXTENSION_ID, msg); // sender.id set
Defensive patterns
Strategy: validation
Validate before calling
// caller-side check before messaging SingleFile
chrome.runtime.sendMessage(SINGLEFILE_ID, { method: 'initiateCapture' }, response => {
if (chrome.runtime.lastError) { /* handle: sender.id missing or not allowed */ }
}); Type guard
function hasExtensionSender(sender) {
return Boolean(sender && typeof sender.id === 'string' && sender.id.length > 0);
} Try / catch
try {
await requestPermission(sender, message);
} catch (error) {
if (error.message.includes('Cannot identify the extension')) {
// reject the request: caller is not an identifiable extension
} else { throw error; }
} Prevention
- Only send external capture requests from real extension contexts
- Use runtime.onMessageExternal and rely on browser-provided sender
- Never synthesize or omit the sender argument in tests against this API
- Register the requesting extension's id in allowedExtensionIds beforehand
When it happens
Trigger: An external runtime.onMessage / onMessageExternal event delivers a request to initiate a SingleFile capture where the `sender` object is absent or `sender.id` is undefined (e.g. message from a web page, service worker context without id, or malformed call).
Common situations: A web page or non-extension script messaging SingleFile directly; a third-party integration calling the external API incorrectly; browser (e.g. Safari/Firefox variant) delivering a sender shape without id; test harness invoking requestPermission without a sender.
Related errors
- Unauthorized sender
- Cannot access the tab contents
- URL is empty
- SingleFile capture was not approved for this extension
- SingleFile capture config must be an object
AI-assisted analysis of gildas-lormeau/SingleFile@517fb7c5cf (2026-09-01).
Data as JSON: /api/errors/dbf719b2e2f56aa7.
Report an issue: GitHub.