Skip to content

Commit

Permalink
fix: correct plugin validation code (#81)
Browse files Browse the repository at this point in the history
The plugin validation endpoint checked if the returned status was 201, 
whereas upstream at 
https://github.com/Kong/kong/blame/f95f755864589ff2884aa7f4f6f3da7e40063
980/kong/api/routes/kong.lua#L157 the endpoint returns a 200. Checking 
against 201 appears to be a hidden error in the original 
implementation, which de facto only failed on errors. 201s are still 
allowed because it's unclear if there was some reason for that check 
originally, and allowing 201s is benign (actual failures will return a 
400).
  • Loading branch information
zackrobichaud committed Aug 25, 2021
1 parent 23fcc2d commit d7c687e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion kong/plugin_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (s *PluginService) Validate(ctx context.Context, plugin *Plugin) (bool, err
if err != nil {
return false, err
}
return resp.StatusCode == http.StatusCreated, nil
return resp.StatusCode == http.StatusCreated || resp.StatusCode == http.StatusOK, nil
}

// listByPath fetches a list of Plugins in Kong
Expand Down

0 comments on commit d7c687e

Please sign in to comment.