The "new-paste" template expects `visibility` to be of the proper enum
type. However, in the error path, the value for visibility comes from
`valid.kwargs`, where it is a plain string. This causes the template to
not set a value for visibility (no radio button selected). This will
cause an exception when the user submits the paste.
Reproduction is e.g. trying to submit an empty paste, then filling in
some data but not selecting a visibility. This can be annoying, as the
user potentially looses the already prepared files.
To fix it, always pass the real visibility value to the template
rendering and remove it from the kwargs.
Thanks to xenrox on IRC for providing the reproduction steps.
Signed-off-by: Conrad Hoffmann <ch@bitfehler.net>
The expectation with the @access directive is that permission
checks are automatically performed by core-go. However this is
actually a no-op for enum values.
Drop the enum value directives to make it clearer that permission
checks must be performed manually.
If the service is not behind a reverse proxy (e.g. during local
development/testing) then this is needed by meta.sr.ht for API discovery
for all services that have a seperate API component. Add this (commented
out) to the example config, to make it easier to discover (and
require less documentation).
Create a new generate.go file which imports github.com/99designs/gqlgen.
This fixes this kind of error because go mod now knows about the
dependency:
/home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/cmd/gen.go:9:2: missing go.sum entry for module providing package github.com/urfave/cli/v2 (imported by github.com/99designs/gqlgen/cmd); to add:
go get github.com/99designs/gqlgen/cmd@v0.13.0
/home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/imports/prune.go:15:2: missing go.sum entry for module providing package golang.org/x/tools/go/ast/astutil (imported by github.com/99designs/gqlgen/internal/imports); to add:
go get github.com/99designs/gqlgen/internal/imports@v0.13.0
/home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/code/packages.go:8:2: missing go.sum entry for module providing package golang.org/x/tools/go/packages (imported by github.com/99designs/gqlgen/internal/code); to add:
go get github.com/99designs/gqlgen/internal/code@v0.13.0
/home/simon/go/pkg/mod/github.com/99designs/gqlgen@v0.13.0/internal/imports/prune.go:16:2: missing go.sum entry for module providing package golang.org/x/tools/imports (imported by github.com/99designs/gqlgen/internal/imports); to add:
go get github.com/99designs/gqlgen/internal/imports@v0.13.0
graph/resolver.go:7: running "go": exit status 1
missing go.sum entry for module providing package github.com/vektah/dataloaden; to add:
go mod download github.com/vektah/dataloaden
loaders/middleware.go:3: running "./gen": exit status 1
It is possible to abandon a paste while editing it on the web UI,
causing the database to have a state that the API was not expecting.
This filters out such pastes.
When we rewrite the paste.sr.ht frontend to work via GraphQL, we should
change the column to non-nullable and remove this where clause.