Last active 1726964411

What breaks in yarnd if we change Twt identity to be "location addressing"

what-breaks.md Raw
The following is a non-exhaustive list of things that break if we change the ways Twts are identified to be "location addressed": 1. Archinving breaks ``` ERRO[0076] error computing archive file for twt error="error: invalid twt hash" ``` Fixing this with the patch: ```patch diff --git a/internal/archive.go b/internal/archive.go index 9f8448c6..d7aaab5d 100644 --- a/internal/archive.go +++ b/internal/archive.go @@ -25,7 +25,6 @@ const ArchiveDir = "archive" var ( ErrTwtAlreadyArchived = errors.New("error: twt already archived") ErrTwtNotArchived = errors.New("error: twt not found in archived") - ErrInvalidTwtHash = errors.New("error: invalid twt hash") ) func ReadArchivedTwt(p string) (types.Twt, error) { @@ -121,10 +120,6 @@ func (a *DiskArchiver) makePath(hash string) (string, error) { return "", err } - if len(bs) < 2 { - return "", ErrInvalidTwtHash - } - // Produces a path structure of: // ./data/archive/[0-9a-f]{2,}/[0-9a-f]+.json components := []string{a.path, fmt.Sprintf("%x", bs[0:1]), fmt.Sprintf("%x.json", bs[1:])} diff --git a/internal/utils.go b/internal/utils.go index f09c59f4..de86166e 100644 --- a/internal/utils.go +++ b/internal/utils.go @@ -134,8 +134,7 @@ func GenerateRandomToken() string { } func DecodeHash(hash string) ([]byte, error) { - encoding := base32.StdEncoding.WithPadding(base32.NoPadding) - return encoding.DecodeString(strings.ToUpper(hash)) + return []byte(hash), nil } func FastHash(data []byte) string { ``` Results in the following Go panic (_crash_): ```console INFO[0008] converging cache with 1 potential peers panic: runtime error: slice bounds out of range [:1] with capacity 0 goroutine 134 [running]: git.mills.io/yarnsocial/yarn/internal.(*DiskArchiver).makePath(0x14000132e70, {0x0?, 0xffffffffffffffff?}) /Users/prologic/Projects/yarnsocial/yarn/internal/archive.go:125 +0x158 git.mills.io/yarnsocial/yarn/internal.(*DiskArchiver).Has(0x103aedf20?, {0x0, 0x0}) /Users/prologic/Projects/yarnsocial/yarn/internal/archive.go:152 +0x24 git.mills.io/yarnsocial/yarn/internal.(*Cache).Converge(0x1400060e150, {0x103c37ff0, 0x14000132e70}) /Users/prologic/Projects/yarnsocial/yarn/internal/cache.go:1418 +0x1ac git.mills.io/yarnsocial/yarn/internal.(*UpdateFeedsJob).Run(0x14001001340) /Users/prologic/Projects/yarnsocial/yarn/internal/jobs.go:167 +0x6c8 git.mills.io/yarnsocial/yarn/internal.(*Server).runStartupJobs(0x140003e2180) /Users/prologic/Projects/yarnsocial/yarn/internal/server.go:723 +0x1cc created by git.mills.io/yarnsocial/yarn/internal.NewServer in goroutine 1 /Users/prologic/Projects/yarnsocial/yarn/internal/server.go:1257 +0x2e34 ``` So fixing this assumption that Twts are valid hashes alone isn't as easy as one might think... Trying to debug this is going to be a bit tricky: For some reason the identity of Twts are now empty: ``` DEBU[0024] hash: DEBU[0024] bs: ``` And even starting with a fresh instance results in broken template logic: ``` ERRO[0024] error executing template error="template: timeline:217:12: executing \"twt\" at <urlForRootConv $.Twt $.User>: error calling urlForRootConv: runtime error: slice bounds out of range [:1] with capacity 0" name=timeline ERRO[0024] error executing template error="error executing template timeline: template: timeline:217:12: executing \"twt\" at <urlForRootConv $.Twt $.User>: error calling urlForRootConv: runtime error: slice bounds out of range [:1] with capacity 0" ``` At this point I can't quite figure out why Twt identiies (_were hases_) are coming through as null. Hmmm So, going to continue on for a bit with `--disable-archive` because that's what's failing right now... 2. The threading model is as expected now completely broken... This _may_ take a while to figure out why :/

Powered by Opengist Load: 7ms