deanishe / deanishe/awgo

`"valid": false` is a bad choice for the default for wf.NewItem

Open
#4 3 comments 0 reactions 0 assignees View on GitHub
opinions wanted
Dominant language
Go
Stars
877
Forks
48
PR merge metrics
No merged PRs in 30d

Description

When calling `wf.NewItem(title)`, the Item struct omits the `Valid` property in the Alfred JSON feedback with a value of `false`, which is really unfortunate because:

1. In the example above, we did not specify a validity setting - if we had wanted one, a call to `wf.NewItem(title).Valid(false)` would be the way to accomplish this
2. When you don't specify `valid: false` in Alfred's item JSON, it assumes you wanted `true` when omitted. The behavior of this library results in the opposite of the Alfred default behavior.
3. The README and docs don't mention this explicitly, so this can be tricky to track down.
4. With valid=false instead of valid=true as the default, the behavior of your workflow is to halt on the go script filter step you created, which can be very confusing a difficult to debug (I know, b/c I just wasted a lot of time finding that bug myself).

I understand that the go struct is likely just defaulting the boolean value to false, but for the reasons I outlined, I recommend that the correct default behavior of this property is use the `omitempty` JSON marshaling option. I'm happy to submit a fix/PR if you agree that this default is both incorrect and unintuitive.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.