Replies: 10 comments 1 reply
-
The 400 error ("Property '0' is not allowed for this method") happens when the payload sent to To fix this, make sure each POST to {
"noteId": "your-note-id",
"type": "label",
"name": "eventcode",
"value": "gcbajw7"
} Batch creation of attributes isn't supported—send one attribute per request. Adjust your automation to avoid sending arrays, and this error should go away. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
@dosu this is not correct. I only send one attribute at a time. This is the JavaScript code I use in my NodeJS application to do so:
|
Beta Was this translation helpful? Give feedback.
-
The error means the server is receiving a payload with a numeric key, which only happens if the body is an array or gets parsed incorrectly. Your code looks correct, but this can happen if the If that's already set, try logging the exact payload and headers sent for both successful and failing requests (using a proxy or network inspector). Also, check if the code calling this function could ever wrap the object in an array, for example, inside a loop or batch operation. Adding a runtime check like The endpoint strictly rejects arrays and any unexpected properties, so the issue is almost always with how the request is constructed or parsed by the server, not the endpoint itself source. To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
@dosu also not the issue. I set this Could it be a race condition or DB lock if a schedule and an event happen to create a note at the same time? Should I add a waiting time between the attribute creation requests? |
Beta Was this translation helpful? Give feedback.
-
@hulmgulm , the validation code in the ETAPI seems correct since it checks the input data: eu.route(router, "post", "/etapi/attributes", (req, res, next) => {
if (req.body.type === "relation") {
eu.getAndCheckNote(req.body.value);
}
const _params = {};
eu.validateAndPatch(_params, req.body, ALLOWED_PROPERTIES_FOR_CREATE_ATTRIBUTE); the validation works by going through each provided member in the data: function validateAndPatch(target: any, source: any, allowedProperties: ValidatorMap) {
for (const key of Object.keys(source)) {
if (!(key in allowedProperties)) {
throw new EtapiError(400, "PROPERTY_NOT_ALLOWED", `Property '${key}' is not allowed for this method.`); So I'm inclined to think it's not a bug in the ETAPI, but somewhere along the way.
|
Beta Was this translation helpful? Give feedback.
-
I've added more logging to my node application, deleted all notes to be created and triggered the creation. From the log, it looks like creating a note attribute fails if another thread creates a note at the same time:
For me it looks like a DB lock issue (or something like that) on Trilium server side. |
Beta Was this translation helpful? Give feedback.
-
Another try using async-mutex library to make sure, that only one note creation at a time runs before the next starts. I also removed the 3sec wait between note and attribute creation. Now the log looks differently. I get way more errors than before:
|
Beta Was this translation helpful? Give feedback.
-
I solved this issue for me by removing async-mutex again and waiting 10 seconds between the creation of a note and creating its attributes. This is an ugly fix but works for my use case. |
Beta Was this translation helpful? Give feedback.
-
@hulmgulm , could you provide a sample script which can reproduce this consistently? It would help debugging the issue on our side. |
Beta Was this translation helpful? Give feedback.
-
I tried to create the simplest code to reproduce this but without that many calls to create a note, I cannot see the issue. If I run this script several times, I see the error occur on my Trilium instance. As you see, there are three different api calls: get day note, create note and create attributes. Without the get day note calls, I cannot reproduce it.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Description
I use ETAPI to create notes on a schedule or on certain events. I never encountered any issues creating the notes themselves but I sometimes encounter the issue in the log below when adding an attribute to a newly created note using http://192.168.2.52/etapi/attributes. I'm waiting for the create note call to finish before creating attributes for it.
Unfortunately, the error does not tell me where what went wrong. Maybe someone can help me here?
TriliumNext Version
0.98.1
What operating system are you using?
Other Linux
What is your setup?
Local + server sync
Operating System Version
Debian
Error logs
Search debug: {
"fulltextTokens": [],
"structuredExpressionTokens": [
{
"token": "#eventcode",
"inQuotes": false,
"startIndex": 0,
"endIndex": 9
},
{
"token": "=",
"inQuotes": false,
"startIndex": 10,
"endIndex": 10
},
{
"token": "gcbajw7",
"inQuotes": false,
"startIndex": 11,
"endIndex": 17
}
],
"expression": {
"name": "DQe",
"orderDefinitions": [],
"limit": 10,
"subExpression": {
"name": "e",
"subExpressions": [
{
"name": "yQe",
"propertyName": "isArchived",
"operator": "=",
"comparedValue": "false"
},
{
"name": "cQe",
"subExpression": {
"name": "MQe"
}
},
{
"name": "bQe",
"attributeType": "label",
"attributeName": "eventcode"
}
]
}
}
}
Got error e [Error]: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395) {
statusCode: 400,
code: 'PROPERTY_NOT_ALLOWED'
}
ERROR: post /etapi/attributes threw exception Property '0' is not allowed for this method. with stacktrace: Error: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395)
Got error e [Error]: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395) {
statusCode: 400,
code: 'PROPERTY_NOT_ALLOWED'
}
ERROR: post /etapi/attributes threw exception Property '0' is not allowed for this method. with stacktrace: Error: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395)
Got error e [Error]: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395) {
statusCode: 400,
code: 'PROPERTY_NOT_ALLOWED'
}
ERROR: post /etapi/attributes threw exception Property '0' is not allowed for this method. with stacktrace: Error: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395)
Got error e [Error]: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395) {
statusCode: 400,
code: 'PROPERTY_NOT_ALLOWED'
}
ERROR: post /etapi/attributes threw exception Property '0' is not allowed for this method. with stacktrace: Error: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395)
200 GET /api/health-check with 15 bytes took 1ms
Got error e [Error]: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395) {
statusCode: 400,
code: 'PROPERTY_NOT_ALLOWED'
}
ERROR: post /etapi/attributes threw exception Property '0' is not allowed for this method. with stacktrace: Error: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395)
Got error e [Error]: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395) {
statusCode: 400,
code: 'PROPERTY_NOT_ALLOWED'
}
ERROR: post /etapi/attributes threw exception Property '0' is not allowed for this method. with stacktrace: Error: Property '0' is not allowed for this method.
at Object.$Fs [as validateAndPatch] (/usr/src/app/main.cjs:2644:4829)
at /usr/src/app/main.cjs:2781:8875
at Function.o (/usr/src/app/main.cjs:2644:3802)
at Function.sqliteTransaction (/usr/src/app/node_modules/better-sqlite3/lib/methods/transaction.js:65:24)
at Object.X9i [as transactional] (/usr/src/app/main.cjs:820:1970)
at /usr/src/app/main.cjs:2644:3821
at /usr/src/app/main.cjs:1:67392
at qv.run (/usr/src/app/main.cjs:1:67016)
at qv.runAndReturn (/usr/src/app/main.cjs:1:67374)
at Object.xCt [as init] (/usr/src/app/main.cjs:6:2395)
Beta Was this translation helpful? Give feedback.
All reactions