From fec99623f3f1393c345d6ad43f5af0adca1f820d Mon Sep 17 00:00:00 2001 From: quobix Date: Tue, 31 Oct 2023 15:44:29 -0400 Subject: [PATCH] ensuring we capture empty responses Signed-off-by: quobix --- datamodel/low/extraction_functions.go | 13 ------------- index/rolodex_remote_loader.go | 4 +++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/datamodel/low/extraction_functions.go b/datamodel/low/extraction_functions.go index e66741f..f355fc0 100644 --- a/datamodel/low/extraction_functions.go +++ b/datamodel/low/extraction_functions.go @@ -61,18 +61,6 @@ func LocateRefNodeWithContext(ctx context.Context, root *yaml.Node, idx *index.S // run through everything and return as soon as we find a match. // this operates as fast as possible as ever collections := generateIndexCollection(idx) - - // if there are any external indexes being used by remote - // documents, then we need to search through them also. - //externalIndexes := idx.GetAllExternalIndexes() - //if len(externalIndexes) > 0 { - // var extCollection []func() map[string]*index.Reference - // for _, extIndex := range externalIndexes { - // extCollection = generateIndexCollection(extIndex) - // collections = append(collections, extCollection...) - // } - //} - var found map[string]*index.Reference for _, collection := range collections { found = collection() @@ -98,7 +86,6 @@ func LocateRefNodeWithContext(ctx context.Context, root *yaml.Node, idx *index.S // perform a search for the reference in the index // extract the correct root - specPath := idx.GetSpecAbsolutePath() if ctx.Value(index.CurrentPathKey) != nil { specPath = ctx.Value(index.CurrentPathKey).(string) diff --git a/index/rolodex_remote_loader.go b/index/rolodex_remote_loader.go index e94144d..69f481c 100644 --- a/index/rolodex_remote_loader.go +++ b/index/rolodex_remote_loader.go @@ -314,7 +314,9 @@ func (i *RemoteFS) Open(remoteURL string) (fs.File, error) { } return nil, clientErr } - + if response == nil { + return nil, fmt.Errorf("empty response from remote URL: %s", remoteParsedURL.String()) + } responseBytes, readError := io.ReadAll(response.Body) if readError != nil {