Description: When using bulk upsert on the v10 environment variables endpoint, the API appears to match existing records by strict equality of the target array rather than checking for overlapping targets. If a variable exists for preview and an upsert request is sent for development and preview, a new variable record is created instead of updating the existing one, resulting in duplicate keys for the same environment.
Reproduction Steps:
# 1. Upsert a variable targeting development and preview when preview already existscurl -s -X POST -H "Authorization: Bearer $VERCEL_TOKEN" -H "Content-Type: application/json" \ "https://api.vercel.com/v10/projects/$PROJECT/env?upsert=true" \ -d '[{"key":"REPRO_DUP","value":"both","type":"encrypted","visibility":"config","target":["development","preview"]}]'
# 2. Check variables - REPRO_DUP now exists twice for the preview targetcurl -s -H "Authorization: Bearer $VERCEL_TOKEN" \ "https://api.vercel.com/v8/projects/$PROJECT/env?decrypt=true" \ | jq '[.envs[] | select(.key=="REPRO_DUP") | {id, target, type, value}]'
# 3. Upsert again with target ["development"]curl -s -X POST -H "Authorization: Bearer $VERCEL_TOKEN" -H "Content-Type: application/json" \ "https://api.vercel.com/v10/projects/$PROJECT/env?upsert=true" \ -d '[{"key":"REPRO_DUP","value":"dev2","type":"encrypted","visibility":"config","target":["development"]}]'
# 4. Result leaves two separate records both targeting previewcurl -s -H "Authorization: Bearer $VERCEL_TOKEN" \ "https://api.vercel.com/v8/projects/$PROJECT/env?decrypt=true" \ | jq '[.envs[] | select(.key=="REPRO_DUP") | {id, target, type, value}]'Expected Behavior: The upsert logic should check for environment target overlaps and either update existing entries or prevent duplicate keys from being assigned to the same target environment.