Error appearing in sync table config:
Syncing Table Name from Test Pack failed - ‘id’ property is undefined or null
This is due to a prop being present in schema, having the same name as the id prop but with some case differences, but not present in returned result. The error is a red herring which makes it difficult to debug (the pack thinks that the other cased prop is the id prop, and that other cased prop is indeed undefined in the result, but this is not obvious).
MRE:
import * as coda from "@codahq/packs-sdk";
export const pack = coda.newPack();
pack.addDynamicSyncTable({
name: "TableName",
listDynamicUrls: async function () {
return [{
display: "foo",
value: "foo",
}];
},
getName: async function () {
return "Foo";
},
getDisplayUrl: async function (context) {
return context.sync!.dynamicUrl!;
},
getSchema: async function (context) {
return coda.makeObjectSchema({
properties: {
name: {
type: coda.ValueType.String,
description: "The name."
},
rowUrl: {
type: coda.ValueType.String,
codaType: coda.ValueHintType.Url,
description: "the URL"
},
RowUrl: { type: coda.ValueType.String, description: "the URL" }, // bug part 1
},
idProperty: "rowUrl",
displayProperty: "name",
featuredProperties: ["name", "rowUrl"],
});
},
identityName: "afoo",
formula: {
name: "Foo",
description: "",
parameters: [
coda.makeParameter({
type: coda.ParameterType.String,
name: "nonOptString",
description: "",
}),
coda.makeParameter({
type: coda.ParameterType.String,
name: "optString",
description: "",
optional: true,
}),
coda.makeParameter({
type: coda.ParameterType.Boolean,
name: "optBoolean",
description: "",
optional: true,
suggestedValue: false
})],
execute: async function (params, context) {
return { result: [
{name: "foo", rowUrl: "bar"}, // bug part 2
{name: "foo2", rowUrl: "baz"} // and here
] };
}
}
});