Dynamic properties in ByLineItem

Hi!

I’m trying to write a Forge ByLine Item using both a handler function to render the content as well as updating the properties dynamically:

modules:
  confluence:contentBylineItem:
    - key: byline-item-key
      title: My custom byline
      function: byLineHandler
      dynamicProperties: propertyHandler

  function:
    - key: byLineHandler
      handler: byline.run
    - key: propertyHandler
      handler: byline.propertyHandler

However, this makes forge deploy complain:

7:2     error    confluence:contentBylineItem should NOT have additional property 'function'  valid-document-required

7:2     error    confluence:contentBylineItem required properties are 'title, function, key' or 'title, resource, key'  valid-document-required

11:6    error    confluence:contentBylineItem property dynamicProperties 'propertyHandler' should be object  valid-document-required

According the documentation here the property handler should be passed a function module as in the example. What am I misunderstanding here?

I had a look at the JSON Schema:

dynamicProperties:
  additionalProperties: false
  type: object
  properties:
    function:
      type: string
      minLength: 1
      maxLength: 255
      pattern: '^[a-zA-Z0-9-_]+$'
  required:
    - function

From here we can see that the last error message you got was trying to tell you what was wrong:

confluence:contentBylineItem property dynamicProperties ‘propertyHandler’ should be object

In short, you should have written:

confluence:contentBylineItem:
    - key: byline-item-key
      title: My custom byline
      function: byLineHandler
      dynamicProperties: 
         function: propertyHandler

At least that is what I get from reading this JSON Schema. Does that work?

Going to go check the docs to see if that was documented well. Yeah, it’s in there but maybe a bit opaque. It says that: dynamicProperties: { function: string } which is saying the same thing but in more Typescript style language.

As a general rule, whenever you are referring to a function from your Manifest that referral should be preceded by function:. If that does not happen it should be a smell.

As an aside, I wrote JSON Schema Viewer and this would have made it much easier to see what was going wrong. You can even see the “Example (YAML)” that shows the correct structure.

For the root of the Forge Manifest JSON Schema just visit this link.

Yes, that did the trick, thank you

1 Like

I tried to refer to a function under modules, that seemed to be the most obvious choice. But now I know. Nice with the schema viewer!

1 Like