Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency in Documentation and Example #365

Closed
gobsej opened this issue Sep 19, 2022 · 6 comments
Closed

Inconsistency in Documentation and Example #365

gobsej opened this issue Sep 19, 2022 · 6 comments
Assignees
Labels
Type/Question Further information is requested

Comments

@gobsej
Copy link

gobsej commented Sep 19, 2022

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
}
@neflyte
Copy link

neflyte commented Sep 19, 2022

Thanks for pointing this out! I'll take another look at the docs to ensure they're correct.

The documentation around bindings is being updated in this PR: mattermost/mattermost-developer-documentation#1111

@gobsej
Copy link
Author

gobsej commented Sep 19, 2022

Okay great, thanks for the reply.

@gobsej gobsej closed this as completed Sep 20, 2022
@hanzei hanzei added the Type/Question Further information is requested label Sep 20, 2022
@luiz-filipe
Copy link

luiz-filipe commented Sep 21, 2022

Is this really solved? Because I tried to follow the quick start guide today, and had the same problem: Using the new documentation here: http://mattermost-dev-docs-preview-pulls.s3-website-us-east-1.amazonaws.com/1111/integrate/apps/quickstart/quick-start-go/

If I copy the bindings.json example file there and install my application the bindings call still fails.

I believe the call prop in the binds need to be replaced by submit.

@gobsej
Copy link
Author

gobsej commented Sep 22, 2022

Oh okay sorry, maybe I closed it to fast. I closed it because it already is worked on, but I should probably wait. Yes the call has to be replaced with submit

@gobsej gobsej reopened this Sep 22, 2022
@neflyte
Copy link

neflyte commented Sep 22, 2022

Yes, you are correct @luiz-filipe. The quick start guides are being updated by @azigler in this PR: mattermost/mattermost-developer-documentation#1106

@hanzei
Copy link
Contributor

hanzei commented Jan 31, 2023

Closing as mattermost/mattermost-developer-documentation#1106 got merged

@hanzei hanzei closed this as completed Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type/Question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants