r/Supernote_dev • u/magic_notetaker • Sep 18 '26
Question Problem with file write permissions (sometimes(!) works)
I need some help here from developers or supernote staff. The strange thing: sometimes it works, sometimes it doesn't, without any code changes at all. As if it flips back between modes, stays there a while and flips. Deinstall or switching plugin off and on did not help. Appreciating any ideas or reports on this
Did anyone have similar experience? This is on the latest beta version Chauvet 2.26.42_beta
This is the logging:
9-18 09:40:57.828 I/ReactNativeJS( 917): '[GtdPara]', 'ensurePluginPermission: calling hasPermission', 'plugin.permission.FILE:WRITE'
09-18 09:40:57.831 I/PluginPermMgr( 917): hasPermission permission:plugin.permission.FILE:WRITE
09-18 09:40:57.831 I/PluginPermMgr( 917): hasPermission is have File Write Permission:true
09-18 09:40:57.833 I/ReactNativeJS( 917): '[GtdPara]', 'ensurePluginPermission: hasPermission', 'plugin.permission.FILE:WRITE', '=>', 1
09-18 09:40:57.834 I/ReactNativeJS( 917): '[GtdPara]', 'ensureFolderExists: start', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings'
09-18 09:40:57.836 D/GtdParaFile( 917): ensureFolder: start path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.838 I/ReactNativeJS( 917): '[GtdPara]', 'ensureFolderExists: done', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings'
09-18 09:40:57.839 I/ReactNativeJS( 917): '[GtdPara]', 'listFolderEntries: start', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings'
09-18 09:40:57.840 D/GtdParaFile( 917): listFolderEntries: start path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.840 D/GtdParaFile( 917): listFolderEntries: exists=true path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.841 D/GtdParaFile( 917): listFolderEntries: raw children=15 path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.847 D/GtdParaFile( 917): listFolderEntries: done entries=15 elapsedMs=7 path=/storage/emulated/0/Note/2 Areas/Atruvia/Meetings
09-18 09:40:57.849 I/ReactNativeJS( 917): '[GtdPara]', 'listFolderEntries: done', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings', '15 entries'
09-18 09:40:57.850 I/ReactNativeJS( 917): '[GtdPara]', 'ensurePluginPermission: calling hasPermission', 'plugin.permission.FILE:WRITE'
09-18 09:40:57.852 I/PluginPermMgr( 917): hasPermission permission:plugin.permission.FILE:WRITE
09-18 09:40:57.852 I/PluginPermMgr( 917): hasPermission is have File Write Permission:true
09-18 09:40:57.854 I/ReactNativeJS( 917): '[GtdPara]', 'ensurePluginPermission: hasPermission', 'plugin.permission.FILE:WRITE', '=>', 1
09-18 09:40:57.855 I/ReactNativeJS( 917): '[GtdPara]', 'createNote: start', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings/2026-09-18 - Dailies.note', 'style_white'
09-18 09:40:57.857 I/HostCommImpl( 917): requestClient uid:1002
09-18 09:40:57.858 I/HostCommImpl( 917): getNoteAppPkgName name:com.supernote.document
09-18 09:40:57.858 I/HostCommImpl( 917): checkAPIAvailable packageName:com.supernote.document==createNote
09-18 09:40:57.860 E/ReactNativeJS( 917): '[GtdPara]', 'createNote: failed', '/storage/emulated/0/Note/2 Areas/Atruvia/Meetings/2026-09-18 - Dailies.note', 'This app is not allowed to use this API. Please call a different API.'
09-18 09:40:57.864 E/ReactNativeJS( 917): '[GtdPara]', 'DailyView: meeting action failed', 'This app is not allowed to use this API. Please call a different API.'
09-18 09:40:57.877 E/unknown:ReactNative( 917): console.error: [GtdPara] createNote: failed /storage/emulated/0/Note/2 Areas/Atruvia/Meetings/2026-09-18 - Dailies.note This app is not allowed to use this API. Please call a different API., js engine: hermes, stack:This is the code block:
export async function createNote(
path: string,
template: string,
isPortrait = true,
): Promise<void> {
const granted = await ensureFileWritePermission();
if (!granted) {
logError('createNote: file write permission not granted', path);
throw new Error('File write permission was not granted.');
}
log('createNote: start', path, template);
const response = (await PluginFileAPI.createNote({
notePath: path,
template,
mode: 0,
isPortrait,
})) as {success: boolean; result?: boolean; error?: {code: number; message: string} | null} | null | undefined;
if (!response || !response.success || response.result === false) {
const message = response?.error?.message || 'Could not create the note.';
logError('createNote: failed', path, message);
throw new Error(message);
}
log('createNote: done', path);
}Here The code for the permission check:
export async function ensurePluginPermission( permission: string, description: string, ): Promise<boolean> { const manager = PluginManager as PermissionAwareManager;
if (
typeof manager.hasPermission !== 'function' ||
typeof manager.requestPermission !== 'function'
) {
log('ensurePluginPermission: host has no runtime permission API, treating as granted', permission);
return
true
;
}
const existing = pending.get(permission);
if (existing) return existing;
const request = (async () => {
try {
log('ensurePluginPermission: calling hasPermission', permission);
const has = Number(
await withTimeout(manager.hasPermission!(permission), `hasPermission(${permission})`),
);
log('ensurePluginPermission: hasPermission', permission, '=>', has);
if (has >
0
) return
true
;
log('ensurePluginPermission: calling requestPermission', permission);
const requested = Number(
await withTimeout(
manager.requestPermission!(permission, description),
`requestPermission(${permission})`,
),
);
log('ensurePluginPermission: requestPermission', permission, '=>', requested);
return requested >
0
;
} catch (e) {
logError(
'ensurePluginPermission: error',
permission,
e instanceof Error ? e.message : String(e),
);
return
false
;
}
})();
pending.set(permission, request);
try {
return await request;
} finally {
pending.delete(permission);
}
}
export function ensureFileReadPermission(): Promise<boolean> {
return ensurePluginPermission(
FILE_READ_PERMISSION,
'Allow GtdPara to read your Project and Area folders.',
);
}
export function ensureFileWritePermission(): Promise<boolean> {
return ensurePluginPermission(
FILE_WRITE_PERMISSION,
'Allow GtdPara to create and update project and area files.',
);
}export async function ensurePluginPermission(
permission: string,
description: string,
): Promise<boolean> {
const manager = PluginManager as PermissionAwareManager;
if (
typeof manager.hasPermission !== 'function' ||
typeof manager.requestPermission !== 'function'
) {
log('ensurePluginPermission: host has no runtime permission API, treating as granted', permission);
return true;
}
const existing = pending.get(permission);
if (existing) return existing;
const request = (async () => {
try {
log('ensurePluginPermission: calling hasPermission', permission);
const has = Number(
await withTimeout(manager.hasPermission!(permission), `hasPermission(${permission})`),
);
log('ensurePluginPermission: hasPermission', permission, '=>', has);
if (has > 0) return true;
log('ensurePluginPermission: calling requestPermission', permission);
const requested = Number(
await withTimeout(
manager.requestPermission!(permission, description),
`requestPermission(${permission})`,
),
);
log('ensurePluginPermission: requestPermission', permission, '=>', requested);
return requested > 0;
} catch (e) {
logError(
'ensurePluginPermission: error',
permission,
e instanceof Error ? e.message : String(e),
);
return false;
}
})();
pending.set(permission, request);
try {
return await request;
} finally {
pending.delete(permission);
}
}
export function ensureFileReadPermission(): Promise<boolean> {
return ensurePluginPermission(
FILE_READ_PERMISSION,
'Allow GtdPara to read your Project and Area folders.',
);
}
export function ensureFileWritePermission(): Promise<boolean> {
return ensurePluginPermission(
FILE_WRITE_PERMISSION,
'Allow GtdPara to create and update project and area files.',
);
}
2
Upvotes
2
u/Decent_Tap_5574 Sep 18 '26
Hey, I ran into something similar while building my plugin, and I think your logs already point to the cause.
Your FILE:WRITE permission isn't the problem. PluginPermMgr grants it on every call. The failure comes from a second, separate check in HostCommImpl.checkAPIAvailable. That check doesn't look at your plugin's permissions at all. It looks at which host app the call is coming from (in your log it resolves to com.supernote.document) and whether that app is allowed to use createNote. So permission granted followed by API rejected isn't a contradiction. They're two different gates.
My best guess for why it's intermittent: your code isn't changing, but the app context the host detects is. It could depend on where the plugin was launched from (a note vs. a PDF/document), what was in the foreground last, or a stale value the host has cached. That would also explain why restarting or re-enabling the plugin doesn't reliably fix it, since that state lives on the host side.
What I'd try next:
If step 2 shows a clean split, you have a workaround until Ratta confirms or fixes it. If it's still random from the same context, that points more strongly to a host bug, and the side-by-side logs are exactly what they'll need.
HTH, All the best!