Skip to content

DESCRIBE returns <unbound> for ClientTemplateParameter bound to Forms$PageVariable.LocalVariable #565

@ako

Description

@ako

Discovered while updating fixture PD06 to mirror the corrected Studio-Pro-produced page in test5 (see #547 follow-up).

Symptom

When a column caption (or any TextTemplate parameter) is bound to a page-level variable via Studio Pro's UI, the BSON stores the binding as:

ClientTemplateParameter {
  AttributeRef: null
  Expression: ""
  SourceVariable: Forms$PageVariable {
    LocalVariable: "Col1Label"
    PageParameter: ""
    SnippetParameter: ""
    ...
  }
}

DESCRIBE page returns CaptionParams: [{1} = <unbound>] because the reader only checks SourceVariable.PageParameter and misses LocalVariable.

mxcli's own writer produces the literal expression form (Expression: "$Col1Label") which DOES round-trip, so this only affects projects edited in Studio Pro UI.

Location

mdl/executor/cmd_pages_describe_pluggable.go:extractTextTemplateParameters — around line 575:

if srcVar, ok := pMap["SourceVariable"].(map[string]any); ok && srcVar != nil {
    if paramName, ok := srcVar["PageParameter"].(string); ok && paramName != "" {
        sourceVarName = paramName
    }
}

Only reads PageParameter. Should also read LocalVariable (page variable), SnippetParameter (snippet parameter), and prefix the result with $.

Suggested fix

if srcVar, ok := pMap["SourceVariable"].(map[string]any); ok && srcVar != nil {
    for _, key := range []string{"LocalVariable", "PageParameter", "SnippetParameter"} {
        if name, ok := srcVar[key].(string); ok && name != "" {
            result = append(result, "$"+name)
            // (continue to next parameter — don't fall through to AttributeRef)
        }
    }
}

Discovered

While correcting mdl-examples/doctype-tests/31-pluggable-datagrid-gallery-v010-examples.mdl PD06 after #547. The Studio-Pro-edited test5 reference has Col1Label as LocalVariable (UI path); Col2Label as Expression: "$Col2Label" (text path). Only the first returns <unbound> in DESCRIBE.

Priority

Low. Cosmetic — affects DESCRIBE accuracy for round-tripping Studio-Pro-edited pages, but mxcli's own write path produces the working Expression form.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions