Content Adaptors error message is unclear

I am trying to adapt the Content Adaptors on my website but I keep getting this error.

error calling AddPage: invalid path ""

[Test Site]

Files of interest inside the stations content section.

the last feature returned contains only one space as value of Name_IMS11.

    "Name_IMS11": " ",

that’s why the addPage fails. - I don’t know why the space is stripped in the error message but in fact a single space is not a valid path :wink:

you should code more defensive and add another bunch of if/with or defaults

code added to your adapter to print the stuff (line 13+)

{{- range $data.features }}
   {{ warnf (debug.Dump .) }}                ### print the feature as JSON
  {{- with .properties }} 
   {{ warnf (debug.Dump .) }}                ### print the properties as JSON
    {{- /* Add page. */}}
    {{- $content := dict "mediaType" "text/markdown" }}
full JSON of problematic feature
{
  "geometry": {
    "coordinates": [
      337250.8530250946,
      10028076.362119032
    ],
    "type": "Point"
  },
  "id": 56,
  "properties": {
    "Branch3": " ",
    "County2": " ",
    "Earthing56": " ",
    "FDB_Last18": " ",
    "FID": 56,
    "Manned50": " ",
    "Name_IMS11": " ",
    "OBJECTID": 57,
    "Ownershi23": " ",
    "Programm58": " ",
    "RCC1": " ",
    "Remote_T57": " ",
    "Ripple_C59": " ",
    "Source": "KETRACO",
    "Street40": " ",
    "Type_Acc42": " ",
    "VHF_Radi55": " "
  },
  "type": "Feature"
}

p.s. ther’s another one that starts with a space: "Name_IMS11": " MAUNGU",

I don’t know how someone can do that with dict values. Not that anyone can do {{ with .Name_IMS11 }} Name: {{ Name_IMS11 }} {{ end }}.

you can check that before you create the dict. At least for the values you are later using to create things.

example:

  • assign to a variable
  • check value,
  • use the variable in the dict (you use it twice)
    {{- $content := dict "mediaType" "text/markdown" }}
    {{- $Name_IMS11 := .Name_IMS11 -}}    ### maybe trim leading trailing white space ...
    {{- if CHECK HERE -}}       
      ### errorf or other handling like skipping, setting a default fe `printf "UNKNOWN-%d" math.Counter`
   {{- end -}}
    {{- $params := dict 
      "Name" $Name_IMS11

Hint: Maybe you want to use one of the ID… values as path.