diff options
author | Florian Klink <flokli@flokli.de> | 2023-10-05T15·28+0300 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-10-07T02·06+0000 |
commit | 9c0d66197bfa60a0c14109a471b6bcdfd61247e1 (patch) | |
tree | df705c367f6055d08d707e25215533ac9f90e462 /tvix/nar-bridge/pkg | |
parent | 4bf541109a9e0a918420a8be1b10564b30edf117 (diff) |
feat(tvix/nar-bridge): do pathInfo.Validate() as additional check r/6719
This should make it quite quick to spot writing code breaking some of the assumptions we have on PathInfo messages ourselves. Change-Id: I480caaec41f8ea5246c3c3081460c7ad12e78569 Reviewed-on: https://cl.tvl.fyi/c/depot/+/9554 Reviewed-by: Connor Brewster <cbrewster@hey.com> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de>
Diffstat (limited to 'tvix/nar-bridge/pkg')
-rw-r--r-- | tvix/nar-bridge/pkg/pathinfosvc/server.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tvix/nar-bridge/pkg/pathinfosvc/server.go b/tvix/nar-bridge/pkg/pathinfosvc/server.go index 464ca6f61b13..d5074a2f3267 100644 --- a/tvix/nar-bridge/pkg/pathinfosvc/server.go +++ b/tvix/nar-bridge/pkg/pathinfosvc/server.go @@ -264,6 +264,20 @@ func (p *PathInfoServiceServer) Get(ctx context.Context, getPathInfoRequest *sto panic("node may not be nil") } + // run Validate on the PathInfo, more as an additional sanity check our code is sound, + // to make sure we populated everything properly, before returning it. + validatedOutPath, err := pathInfo.Validate() + if err != nil { + panic("pathinfo failed validation") + } + if narInfo.StorePath != validatedOutPath.Absolute() { + panic(fmt.Sprintf( + "StorePath returned from Validate() mismatches the one from .narinfo (%s vs %s)", + validatedOutPath.Absolute(), + narInfo.StorePath), + ) + } + return pathInfo, nil // TODO: Deriver, System, CA |