Skip to content

Inconsistency in Documentation and Example #365

@gobsej

Description

@gobsej

I experienced following error after installing a mattermost app on the server: (only) one of "submit", "form", or "bindings" must be set in a binding

After looking at the code I found following switch case inside the function cleanAppBinding which specifies that one and only one the properties submit, form or bindings needs to be specified (this also applies for sub-bindings). According to the example and the quick start guide this should not be the case.

hasBindings := len(b.Bindings) > 0
hasForm := b.Form != nil
hasSubmit := b.Submit != nil
switch {
	// valid cases
	case hasBindings && !hasForm && !hasSubmit:
		var newProblems error
		b.Bindings, newProblems = cleanAppBindings(app, b.Bindings, fql, userAgent, conf)
		if newProblems != nil {
			problems = multierror.Append(problems, newProblems)
		}
		if len(b.Bindings) == 0 {
			// We do not add bindings without any valid sub-bindings
			return nil, problems
		}

	case hasForm && !hasSubmit && !hasBindings:
		clean, err := cleanForm(*b.Form, conf, app.AppID)
		if err != nil {
			problems = multierror.Append(problems, err)
		}
		b.Form = &clean

	case hasSubmit && !hasBindings && !hasForm:
		// nothing to clean for submit

	default:
		problems = multierror.Append(problems, errors.Errorf(`%s: (only) one of  "submit", "form", or "bindings" must be set in a binding`, fql))
		return nil, problems
}

Metadata

Metadata

Assignees

Labels

Type/QuestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions