Skip to content

Commit

Permalink
fix(clustering/sync): insert default values to delta entities before …
Browse files Browse the repository at this point in the history
…validation
  • Loading branch information
chobits committed Jan 23, 2025
1 parent 6837e4d commit 8e17d88
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions kong/clustering/services/sync/validate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ local function validate_deltas(deltas, is_full_sync)
-- unknown field.
-- TODO: On the CP side, remove ws_id from the entity and set it only
-- in the delta.
local ws_id = delta_entity.ws_id
delta_entity.ws_id = nil -- clear ws_id

local ok, err_t = dao.schema:validate(delta_entity)

delta_entity.ws_id = ws_id -- restore ws_id
-- needs to insert default values into entity to align with the function
-- dc:validate(input), which will call process_auto_fields on its
-- entities of input.
local copy = dao.schema:process_auto_fields(delta_entity, "insert")
copy.ws_id = nil

local ok, err_t = dao.schema:validate(copy)
if not ok then
errs[#errs + 1] = { [delta_type] = err_t }
end
Expand Down

0 comments on commit 8e17d88

Please sign in to comment.