1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-11-24 20:06:55 +01:00
unleash.unleash/src/lib
Thomas Heartman e125c0f072
fix(1-3928): prevent overwriting existing values in instance store (#10360)
Fixes a bug in the instance store where insert and bulkUpsert would
overwrite existing properties if there was a row there already. Now
it'll ignore any properties that are undefined.

The implementation is lifted directly from
`src/lib/db/client-applications-store.ts` (line 107 atm).

Additionally, I've renamed the `insert` method to `upsert` to make it
clearer what it does (and because we already have `bulkUpsert`). The
method seems to only be used in tests, anyway. I do not anticipate any
changes to be required in enterprise (I've checked).

## Discussion points:

This implementation uses `delete` to remove properties from the object.
Why didn't I do it some other way? Two main reasons:
1. We've had this implementation for 4 years in the client applications
store. If there were serious issues with it, we'd probably know by know.
(Probably.)
2. The only way I can think of without deleting, would be to use
`Object.fromEntries` and `Object.toEntries` and either map or reduce.
That'll double the amount of property iterations we'll need to do.

So naively, this strikes me as being more efficient. If you know better
solutions, I will of course be happy to take them. If not, I'd like to
leave this as is and then change it if we see that it's causing issues.
2025-07-16 12:10:15 +00:00
..
__snapshots__ feat: add prometheusImpactMetricsApi option to configuration (#10168) 2025-06-18 17:53:08 +02:00
addons fix: remove console log from tests (#10292) 2025-07-03 10:07:53 +03:00
db fix(1-3928): prevent overwriting existing values in instance store (#10360) 2025-07-16 12:10:15 +00:00
domain/project-health feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
error chore: fix typo (#10016) 2025-05-19 11:10:16 +00:00
events feat: start storing every transaction id in events table (#10236) 2025-06-30 16:00:57 +03:00
features fix: don't overwrite seenClients in instance-service; merge if same client appears again (#10357) 2025-07-16 14:02:25 +02:00
interfaces feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
middleware feat: decouple error impact metrics from logger (#10311) 2025-07-04 13:41:19 +02:00
openapi fix: don't overwrite seenClients in instance-service; merge if same client appears again (#10357) 2025-07-16 14:02:25 +02:00
routes fix: make user creation transactional (#10327) 2025-07-08 10:17:16 +00:00
schema chore!: remove deprecated default env from new installs (#10080) 2025-06-06 12:02:21 +02:00
services fix: make user creation transactional (#10327) 2025-07-08 10:17:16 +00:00
tags feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
types fix(1-3928): prevent overwriting existing values in instance store (#10360) 2025-07-16 12:10:15 +00:00
users feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
util chore: bring back impact metrics (#10212) 2025-06-25 17:03:09 +02:00
app.test.ts task: migrate tests to vitest 2025-05-16 11:19:10 +02:00
app.ts fix: frontend API CORS (#10301) 2025-07-04 10:47:11 +02:00
create-config.test.ts chore(apitoken)!: remove ILegacyApiTokenCreate (#10072) 2025-06-04 11:41:37 +02:00
create-config.ts feat: add prometheusImpactMetricsApi option to configuration (#10168) 2025-06-18 17:53:08 +02:00
default-custom-auth-deny-all.ts feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
internals.ts feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
logger.test.ts feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
logger.ts feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
metric-events.ts fix: add a metric to track client registrations (#9314) 2025-02-17 09:01:19 +01:00
metrics-gauge.test.ts feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
metrics-gauge.ts feat: Unleash v7 ESM migration (#9877) 2025-05-14 09:47:12 +02:00
metrics.test.ts chore!: remove deprecated default env from new installs (#10080) 2025-06-06 12:02:21 +02:00
metrics.ts feat: Using impact metrics with flags (#10355) 2025-07-15 08:42:38 +02:00
server-impl.test.ts task: migrate tests to vitest 2025-05-16 11:19:10 +02:00
server-impl.ts chore: Export IClientInstance from server-impl. (#10354) 2025-07-14 15:36:18 +02:00