diff --git a/core/block/import/notion/api/block/link.go b/core/block/import/notion/api/block/link.go index c84e79cb8..57f82c370 100644 --- a/core/block/import/notion/api/block/link.go +++ b/core/block/import/notion/api/block/link.go @@ -298,14 +298,14 @@ func getTargetBlock(importContext *api.NotionImportContext, pageIDToName, notion if targetBlockID, ok = notionIDsToAnytype[id]; ok { return targetBlockID, nil } else { - err = fmt.Errorf("%s '%s'", objectNotFoundMessage, title) + err = fmt.Errorf("%s '%s'", objectNotFoundMessage, hashText(title)) log.With("notionID", hashText(id)).With("title", hashText(title)).Errorf("getTargetBlock: anytype id not found") } } else if len(idsWithGivenName) > 1 { - err = fmt.Errorf("%s '%s'", ambiguousPageMessage, title) + err = fmt.Errorf("%s '%s'", ambiguousPageMessage, hashText(title)) log.With("title", hashText(title)).With("options", len(idsWithGivenName)).Warnf("getTargetBlock: ambligious page title") } else { - err = fmt.Errorf("%s '%s'", pageNotFoundMessage, title) + err = fmt.Errorf("%s '%s'", pageNotFoundMessage, hashText(title)) log.With("title", hashText(title)).Errorf("getTargetBlock: target not found") } diff --git a/core/session/service.go b/core/session/service.go index 84dcb6521..7f26930b8 100644 --- a/core/session/service.go +++ b/core/session/service.go @@ -113,7 +113,7 @@ func validateToken(privKey []byte, rawToken string) error { return privKey, nil }) if err != nil { - return fmt.Errorf("parse token %s: %w", rawToken, err) + return fmt.Errorf("parse token: %w", err) } if token != nil && !token.Valid { diff --git a/core/subscription/service.go b/core/subscription/service.go index cef886dce..24b9b8074 100644 --- a/core/subscription/service.go +++ b/core/subscription/service.go @@ -535,7 +535,7 @@ func (s *service) filtersFromSource(spaceID string, sources []string) (database. for _, relationID := range idsByType[smartblock.SmartBlockTypeRelation] { relationDetails, err := s.objectStore.GetDetails(relationID) if err != nil { - return nil, fmt.Errorf("get relation %s details: %w", relationDetails, err) + return nil, fmt.Errorf("get relation %s details: %w", relationID, err) } relTypeFilter = append(relTypeFilter, database.FilterExists{ Key: pbtypes.GetString(relationDetails.Details, bundle.RelationKeyRelationKey.String()), diff --git a/util/builtinobjects/builtinobjects.go b/util/builtinobjects/builtinobjects.go index fbf4dca84..8be4d9ae9 100644 --- a/util/builtinobjects/builtinobjects.go +++ b/util/builtinobjects/builtinobjects.go @@ -4,6 +4,7 @@ import ( "archive/zip" "bytes" "context" + _ "embed" "fmt" "io" "net/http" @@ -29,8 +30,6 @@ import ( "github.com/anyproto/anytype-heart/util/constant" oserror "github.com/anyproto/anytype-heart/util/os" "github.com/anyproto/anytype-heart/util/pbtypes" - - _ "embed" ) const ( @@ -195,7 +194,7 @@ func (b *builtinObjects) CreateObjectsForExperience(ctx context.Context, spaceID return err } if resp.StatusCode != http.StatusOK { - return fmt.Errorf("failed to fetch experience from '%s': not OK status code: %s", source, resp.Status) + return fmt.Errorf("failed to fetch experience: not OK status code: %s", resp.Status) } defer func() { if err = resp.Body.Close(); err != nil { @@ -237,7 +236,7 @@ func (b *builtinObjects) InjectMigrationDashboard(spaceID string) error { func (b *builtinObjects) inject(ctx session.Context, spaceID string, useCase pb.RpcObjectImportUseCaseRequestUseCase, archive []byte) (err error) { path := filepath.Join(b.tempDirService.TempDir(), time.Now().Format("tmp.20060102.150405.99")+".zip") if err = os.WriteFile(path, archive, 0644); err != nil { - return fmt.Errorf("failed to save use case archive to temporary file: %s", err) + return fmt.Errorf("failed to save use case archive to temporary file: %w", err) } if err = b.importArchive(context.Background(), spaceID, path); err != nil { diff --git a/util/unsplash/unsplash.go b/util/unsplash/unsplash.go index 6311433d8..288c16a37 100644 --- a/util/unsplash/unsplash.go +++ b/util/unsplash/unsplash.go @@ -238,23 +238,23 @@ func (l *unsplashService) Download(ctx context.Context, id string) (imgPath stri client := http.DefaultClient resp, err := client.Do(req) if err != nil { - return "", fmt.Errorf("failed to download file from unsplash: %s", err) + return "", fmt.Errorf("failed to download file from unsplash: %w", err) } defer resp.Body.Close() tmpfile, err := ioutil.TempFile(l.tempDirProvider.TempDir(), picture.ID) if err != nil { - return "", fmt.Errorf("failed to create temp file: %s", err) + return "", fmt.Errorf("failed to create temp file: %w", err) } _, _ = io.Copy(tmpfile, resp.Body) tmpfile.Close() err = injectIntoExif(tmpfile.Name(), picture.Artist, picture.ArtistURL, picture.Description) if err != nil { - return "", fmt.Errorf("failed to inject exif: %s", err) + return "", fmt.Errorf("failed to inject exif: %w", err) } p, err := filepath.Abs(tmpfile.Name()) if err != nil { - return "", fmt.Errorf("failed to inject exif: %s", err) + return "", fmt.Errorf("failed to inject exif: %w", err) } go func(cl *unsplash.Unsplash) { @@ -276,7 +276,7 @@ func injectIntoExif(filePath, artistName, artistUrl, description string) error { jmp := jpegstructure.NewJpegMediaParser() intfc, err := jmp.ParseFile(filePath) if err != nil { - return fmt.Errorf("failed to open file to read exif: %s", err) + return fmt.Errorf("failed to open file to read exif: %w", err) } sl := intfc.(*jpegstructure.SegmentList) rootIb, err := sl.ConstructExifBuilder() @@ -295,11 +295,11 @@ func injectIntoExif(filePath, artistName, artistUrl, description string) error { f, err := os.OpenFile(filePath, os.O_RDWR|os.O_TRUNC, 0755) defer f.Close() if err != nil { - return fmt.Errorf("failed to open file to write exif: %s", err) + return fmt.Errorf("failed to open file to write exif: %w", err) } err = sl.Write(f) if err != nil { - return fmt.Errorf("failed to write exif: %s", err) + return fmt.Errorf("failed to write exif: %w", err) } return nil }