POSTs on resources with more than one layer of translations fail w/ 500 logging: TypeError: Cannot read properties of undefined (reading 'idField') #794
1) 04 native translation tests
translate v3 model
should create a campus for /v3 that is a faculty on latest model:
Error: expected 201 "Created", got 500 "Internal Server Error"
TypeError: Cannot read properties of undefined (reading 'idField')
at getIdField (/home/.../pinejs/src/sbvr-api/sbvr-utils.ts:1171:67)
at runQuery (/home/.../pinejs/src/sbvr-api/sbvr-utils.ts:1790:49)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async runPost (/home/.../pinejs/src/sbvr-api/sbvr-utils.ts:1872:37)
at async runRequest (/home/.../pinejs/src/sbvr-api/sbvr-utils.ts:1600:19)
at async /home/.../pinejs/src/sbvr-api/sbvr-utils.ts:1429:15
at async Object.transaction (/home/.../pinejs/src/database-layer/db.ts:472:20)
at async runTransaction (/home/.../pinejs/src/sbvr-api/sbvr-utils.ts:1751:9)
at async /home/.../pinejs/src/sbvr-api/sbvr-utils.ts:1406:12
at async mapTill (/home/.../pinejs/src/sbvr-api/control-flow.ts:50:19)
1) should create a campus for /v3 that is a faculty on latest model
That ^ test case is doing POST /v3/campus where v3 campus gets translated to v4 faculty, which then is a passthrough-"translated" to v5 faculty (which is the DB model).
2024-08-23T08:03:54.597Z ::ffff:127.0.0.1 a/2 POST /v6/application_config_variable 500 63.272ms -
1) Should see the application-specific value if one exists
TypeError: Cannot read properties of undefined (reading 'idField')
at getIdField (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1171:67)
at runQuery (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1790:49)
at processTicksAndRejections (node:internal/process/task_queues:105:5)
at async runPost (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1872:37)
at async runRequest (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1600:19)
at async /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1429:15
at async Object.transaction (/usr/src/app/node_modules/@balena/pinejs/src/database-layer/db.ts:472:20)
at async runTransaction (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1751:9)
at async /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1406:12
at async mapTill (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/control-flow.ts:50:19)
at async /usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1396:20
at async handleODataRequest (/usr/src/app/node_modules/@balena/pinejs/src/sbvr-api/sbvr-utils.ts:1474:21)
Running the test cases in v w/o the src changes results: See: https://github.com/balena-io/pinejs/commit/ee24e9ce54947f7f12be581103b865836f8dfb6f
That ^ test case is doing
POST /v3/campus
where v3 campus gets translated to v4 faculty, which then is a passthrough-"translated" to v5 faculty (which is the DB model).Respectively in https://github.com/balena-io/open-balena-api/commit/51b32c78471bd7ae0d9fb647dd09286de8aedf8a
POST /v6/application_config_variable
fails w/ a 500, after being translated to v7 application_config_variable and then to resin application_config_variable and similarly fails with:See: https://github.com/balena-io/open-balena-api/actions/runs/10522121234/job/29154165304?pr=1684