Skip to content

Commit

Permalink
fix: return not found on invalid metadata keys
Browse files Browse the repository at this point in the history
  • Loading branch information
tinyzimmer committed Oct 20, 2023
1 parent 8f39aff commit b44cc03
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions examples/id-auth/deploy/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ patches:
- --host.services.api.disabled=false
- --host.services.api.mesh-enabled=true
- --host.wireguard.listen-port=61820
- --manager.enable-metadata-id-tokens=true
6 changes: 6 additions & 0 deletions internal/metadata/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"net"
"net/http"
Expand Down Expand Up @@ -197,6 +198,11 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
result, err := jmespath.Search(path, jsondata)
if err != nil {
if errors.As(err, &jmespath.SyntaxError{}) {
// Return a not found error
http.Error(w, "null", http.StatusNotFound)
return
}
s.returnError(w, err)
return
}
Expand Down

0 comments on commit b44cc03

Please sign in to comment.