[bug] Packs Editor picky about \n and trailing comma

Steps to reproduce:

  1. Create a new pack using the Hello World sample code
  2. Create schema as per the following:
const OutputSchema = coda.makeObjectSchema({
  properties: {
    output: { type: coda.ValueType.String },
    prop1: { type: coda.ValueType.String },
    prop2: { type: coda.ValueType.String },
    // Add more properties here.
  displayProperty: "output", // Which property above to display by default.
  1. Modify coda’s pack.addFormula like so:
  resultType: coda.ValueType.Object,  // instead of string
  schema: OutputSchema,               // add this property
  execute: async function ([name], context) { //modify execution function
    return {output: "out", prop1: "0", prop2: "str"}
  1. Run the formula in a test doc

Expected Output:

It should literally spit out the object literal you just gave it

Actual Output

The first (display) property “output” is entirely missing. Other two properties still appear.

See test doc and source code below. I’ve created four different formulas that all should be identical… but give different output because of missing newlines or trailing commas in the object literal.

1 Like

Hi @Ryan_Martens2 - Thanks for the detailed bug report! I think the problem here is not actually a bug, but instead a tricky typo:

From Hello1:

    return {
      output: "out",
      prop1: "0",
      prop2: "str",

From Hello2:

    return {
      ouput: "out",
      prop1: "0",
      prop2: "str"

You’ll notice the key in the former is output with two t’s, while in the latter it’s ouput with the first “t” missing. ouput doesn’t correspond to a property so it’s value is dropped, while the display property output is not set so the chip displays with no title.

1 Like

Oh my, well that’s embarrassing. But also comforting to know that the editor isn’t so easily broken.

Should I edit or delete this post then?

1 Like

I would say leave it up! I’ve run into the issue of empty display values a lot of times, and it’s useful to show others one common cause.

1 Like