~bigbes/core-go

583d0b1b — Simon Ser 2 years ago
client/graphql: handle GraphQL errors

Instead of leaving it up to the caller to check for GraphQL errors,
centralize in core-go.
a88277c1 — Simon Ser 2 years ago
email: improve mail.ParseAddress error message
453dcaef — Simon Ser 2 years ago
server/directives: disambiguate AnonInternal error message

AUTH_INTERNAL won't work with AnonInternal.
53966da2 — Simon Ser 2 years ago
Drop gqlparser v1 dependency

Only use v2 throughout the repository.
2e7ac4ec — Conrad Hoffmann 2 years ago
Update and simplify build manifest

Alpine 3.14 uses Go 1.16, but go.mod says 1.17. Also, no external
repository should be required for core-go.
cd878493 — Conrad Hoffmann 2 years ago
webhooks: skip webhooks with expired credentials

The documentation states [1]:

> When the original authentication method becomes invalid (such as the
> expiration of or revocation of an OAuth 2.0 bearer token), the
> webhook is disabled.

However, this is currently not the case. Expired webhooks are indeed
filtered out in virtually all GraphQL queries (by means of core-go's
FilterWebhooks [2]), so users cannot see or delete them. They are _not_
filtered out upon scheduling, however. This commit fixes that.

The symptoms of this are that active webhooks may simply not be run - if
a user has both an expired and a valid, active webhook for some event,
the scheduling will retrieve both, fail on the expired one, and stop
processing, without any feedback to the user who scheduled the hooks.

This is a problem across all services, so core-go seems like the best
place to fix this.

[1]: https://man.sr.ht/graphql.md#webhook-authentication
[2]: https://git.sr.ht/~sircmpwn/core-go/tree/master/item/webhooks/config.go#L74,81
d2ad494f — Simon Ser 2 years ago
Migrate to chi v5

v1 is not maintained anymore.
3902e4bd — Simon Ser 2 years ago
database: don't panic on context.DeadlineExceeded

Checking context.Cancelled is not enough, I also see the same issue
with context.DeadlineExceeded:

    panic: Transaction error: driver: bad connection
    Closure error: context deadline exceeded

    goroutine 66664 [running]:
    git.sr.ht/~sircmpwn/core-go/database.WithTx({0x5578e1847a58, 0xc0002c44e0}, 0x50?, 0xc000285f38)
            e7b8e02696a1">git.sr.ht/~sircmpwn/core-go@v0.0.0-20231129165057-e7b8e02696a1/database/middleware.go:74 +0x2ce
    git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.fetchUsersByID.func1({0xc0002cf190, 0x1, 0x1})
            git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/middleware.go:34 +0x118
    git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.(*usersByIDLoaderBatch).end(...)
            git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/usersbyidloader_gen.go:222
    git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.(*usersByIDLoaderBatch).startTimer(0xc00044a360, 0xc00042d380)
            git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/usersbyidloader_gen.go:218 +0xe7
    created by git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.(*usersByIDLoaderBatch).keyIndex
            git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/usersbyidloader_gen.go:191 +0x119
86ad9b5a — Conrad Hoffmann 2 years ago
server/email: use go-message for address parsing

No need to additionally depend on net/mail
e7b8e026 — Simon Ser 2 years ago
database: print both errors in WithTx

Make it easier to debug panics by printing both errors instead of
sending one of them to /dev/null.
7f5f7071 — Simon Ser 2 years ago
database/middleware: fix error value used in panic

We were checking txErr, but panic'ing with err.

Fixes: a06a6247898c ("database: don't panic with ErrBadConn")
cfae7bae — Simon Ser 3 years ago
Upgrade dependencies
72c2f060 — Simon Ser 3 years ago
database: specify field name for graphql.CollectedField

Newer versions of the graphql package add new fields to this struct.
This results in errors:

    database/ql.go:40:4: too few values in struct literal of type graphql.CollectedField
    database/ql.go:71:4: too few values in struct literal of type graphql.CollectedField
bf4fe19c — наб 2 years ago
email: EnqueueStd: set Content-Type with charset=UTF-8 instead of just text/plain

Mails are now
	--11d2cbf164a9ae0dfbb310faf818762607dcfd20aa74e07c7be0eec1458d
	Mime-Version: 1.0
	Content-Transfer-Encoding: quoted-printable
	Content-Type: text/plain; charset=UTF-8

	=D1=82=D1=80=D1=83=D0=BF=D0=B08

	--=20
	View on the web: http://192.168.1.101:5003/~nab2/trupa/8
	--11d2cbf164a9ae0dfbb310faf818762607dcfd20aa74e07c7be0eec1458d
	Content-Type: application/pgp-signature

	-----BEGIN PGP MESSAGE-----

	wnUEARYIACcFAmUavj0JkKdioLsBS5scFiEE+ts/9LaoXcZuSmrHp2KguwFLmxwA
	AIm9AP9KB4cZyiby7jiiRMRESDeJXrdb4kNqyA3D3nVOt14bKgD/UiDfUKE1MwiV
	pOqj/S0wiJdChKW52zRAkwuQ7PtKkgI=
	=AiY9
	-----END PGP MESSAGE-----
	--11d2cbf164a9ae0dfbb310faf818762607dcfd20aa74e07c7be0eec1458d--
which is correct, and decodes correctly in neomutt.

Fixes: https://lists.sr.ht/~sircmpwn/sr.ht-discuss/%3C4uxbrlspm45s5i4bhhmqgmry374i22oqcxedtowda5zrzd7bpf2%405pyosds5owty%3E
a06a6247 — Simon Ser 3 years ago
database: don't panic with ErrBadConn

Sometimes we're panic'ing like so:

    panic: driver: bad connection

    goroutine 9333 [running]:
    git.sr.ht/~sircmpwn/core-go/database.WithTx({0x561c2e623478, 0xc0002b6ed0}, 0x50?, 0xc00025ff38)
    	65b1657b30a1">git.sr.ht/~sircmpwn/core-go@v0.0.0-20230816134313-65b1657b30a1/database/middleware.go:57 +0x1fc
    git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.fetchUsersByID.func1({0xc0002d80f0, 0x1, 0x1})
    	git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/middleware.go:34 +0x118
    git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.(*usersByIDLoaderBatch).end(...)
    	git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/usersbyidloader_gen.go:222
    git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.(*usersByIDLoaderBatch).startTimer(0xc0004e5380, 0xc0000e5140)
    	git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/usersbyidloader_gen.go:218 +0xe7
    created by git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders.(*usersByIDLoaderBatch).keyIndex
    	git.sr.ht/~sircmpwn/builds.sr.ht/api/loaders/usersbyidloader_gen.go:191 +0x119

I believe this is a pq bug, see the linked bug report. Stop
panic'ing in that case.
d83af997 — Simon Ser 3 years ago
auth: make DecodeGrants return an error

We'll use this function to validate grants passed in via
builds.sr.ht manifests.
65b1657b — Simon Ser 3 years ago
auth: add AuthContext.Access

Same logic as server.Access, but lower-level. Useful to check for
a permission not covered by the GraphQL schema @access directives
(such as builds.sr.ht secrets).
a941162e — Simon Ser 3 years ago
server/email: don't panic in EmailRecover

A panic in here is not great, because this function is supposed to
be the panic handler. Let's just log the error instead.
1fd2476d — Simon Ser 3 years ago
server/email: log missing mail::error-to, treat empty string as unset

Log a message when mail::error-to is unset, just in case the admin
forgot to set it. Don't try to parse an email address if error-to
is set to the empty string (the default value in the default config
file).
2f239415 — Simon Ser 3 years ago
server/email: simplify and cleanup

- Only print the error once
- Remove unnecessary var
- Use debug.Stack instead of hand-rolled logic
- Ignore json.Marshal errors in a simpler way
Next