Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for ignoring non-existent documents #33174

Merged
merged 2 commits into from
Jan 31, 2025
Merged

Conversation

mpolden
Copy link
Member

@mpolden mpolden commented Jan 24, 2025

The user might want to read a set of documents where one or more of them may not
exist, without CLI returning errors. This was requested by @wix-mikej.

@bratseth or @kkraune

@wix-mikej
Copy link
Contributor

There is an important distinction between ignoring missing document errors, and ignoring all errors which this diff appears to do. We wanted the "document missing" error still reported via stderr (so it didn't break vespa feed), but didn't want it to exit early (or with an error). If it ran into any other errors it exits w/ failure and we logged the error for review or retry.

In the end we used the following change against v8.460.16:

diff --git a/client/go/internal/cli/cmd/document.go b/client/go/internal/cli/cmd/document.go
index 267f0e91c29..4e084c20c77 100644
--- a/client/go/internal/cli/cmd/document.go
+++ b/client/go/internal/cli/cmd/document.go
@@ -122,7 +122,9 @@ func readDocuments(ids []string, timeoutSecs int, waiter *Waiter, printCurl bool
        for _, docId := range parsedIds {
                result := client.Get(docId, fieldSet)
                if err := printResult(cli, operationResult(true, document.Document{Id: docId}, service, result), true); err != nil {
-                       return err
+                       if result.HTTPStatus != 404 {
+                               return err
+                       }
                }
        }

Also, I apologize for not providing a PR for our change as I had indicated I would. We've been really busy launching a couple things, and I hadn't had a chance to put something together. What you have is basically what I was considering, save the detail above.

@mpolden
Copy link
Member Author

mpolden commented Jan 27, 2025

Thanks! I considered ignoring 404 only, but thought that might be too strict for your use case. I'll make the change.

@kkraune kkraune requested a review from arnej27959 January 28, 2025 10:00
arnej27959
arnej27959 previously approved these changes Jan 29, 2025
Copy link
Member

@arnej27959 arnej27959 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me

@mpolden
Copy link
Member Author

mpolden commented Jan 30, 2025

Needs another approval after I fixed a conflict.

Copy link
Member

@arnej27959 arnej27959 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@mpolden mpolden merged commit 705490c into master Jan 31, 2025
6 checks passed
@mpolden mpolden deleted the mpolden/ignore-missing branch January 31, 2025 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants