Repository navigation
Conversation
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
|
||
| private static User updateBot(TestNamespace ns) { | ||
| HttpClient admin = SdkClients.adminClient().getHttpClient(); | ||
| User bot = admin.execute(HttpMethod.GET, "/v1/users/name/" + BOT, null, User.class); |
There was a problem hiding this comment.
Both tests update the shared ingestion-bot, while integration tests run concurrently. storedEventOf selects an event using only that bot's ID, so it can check the other test's update instead of its own. The Java guide requires TestNamespace to isolate test data. Create a separate bot for each test and use its ID throughout. This requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
| int versions = handle.createUpdate(removeFromVersionsSql(connectionType)).execute(); | ||
| LOG.info("Removed {} from {} user versions", AUTH_MECHANISM_FIELD, versions); | ||
| } | ||
|
|
||
| private static String removeFromVersionsSql(ConnectionType connectionType) { | ||
| return switch (connectionType) { | ||
| case MYSQL -> "UPDATE entity_extension" | ||
| + " SET json = JSON_REMOVE(json, '$.authenticationMechanism')" | ||
| + " WHERE extension LIKE 'user.version.%'" | ||
| + " AND JSON_CONTAINS_PATH(json, 'one', '$.authenticationMechanism')"; | ||
| case POSTGRES -> "UPDATE entity_extension SET json = json - 'authenticationMechanism'" | ||
| + " WHERE extension LIKE 'user.version.%'" | ||
| + " AND json -> 'authenticationMechanism' IS NOT NULL"; | ||
| }; | ||
| } |
There was a problem hiding this comment.
⚠️ Quality: Version cleanup is one unbatched UPDATE over all of entity_extension
removeFromVersionsSql runs a single UPDATE entity_extension ... WHERE extension LIKE 'user.version.%' statement. The primary key is (id, extension), so a LIKE on the second column cannot use the index. The statement scans the version and extension rows of every entity type in the tenant.
This contradicts the Accepted record ADR:2026-10-09-data-migration-backfills-walk-ids-in-batches. That record requires a backfill on a table not bounded by an indexed predicate to walk keyset pages of 500 ids that commit separately. It exists because a whole-table statement on a roughly 115k-table tenant was killed by the database on every attempt. Under runOnce, the same kill would block the 2.1.0 upgrade.
Fix: walk the ids of user entities in pages (for example with IdBatches.fold over user_entity ids), add id IN (<ids>) to the UPDATE, and keep the JSON_CONTAINS_PATH / IS NOT NULL predicate so the step can resume. The alternative is a record that supersedes the ADR.
Restrict each UPDATE to a page of user ids, using the existing IdBatches helper (adapt to its signature).:
case MYSQL -> "UPDATE entity_extension"
+ " SET json = JSON_REMOVE(json, '$.authenticationMechanism')"
+ " WHERE id IN (<ids>) AND extension LIKE 'user.version.%'"
+ " AND JSON_CONTAINS_PATH(json, 'one', '$.authenticationMechanism')";
case POSTGRES -> "UPDATE entity_extension SET json = json - 'authenticationMechanism'"
+ " WHERE id IN (<ids>) AND extension LIKE 'user.version.%'"
+ " AND json -> 'authenticationMechanism' IS NOT NULL";
Was this helpful? React with 👍 / 👎
| .flatMap(List::stream) | ||
| .map(FieldChange::getName) | ||
| .toList(); | ||
| assertTrue(changed.contains("description"), "The merged change must hold the edits"); |
There was a problem hiding this comment.
Field name bypasses required convention
The new assertion uses changed.contains("description"), but the Java guide forbids raw string literals in .contains() calls. Use a named constant for the field. This repository requirement must be satisfied before merging.
Context Used: AGENTS.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Code Review
|
| Compact |
|
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source
|
Replaced by PR #36251, which combines this change with its companion fix in one PR. |
|



Describe your changes:
A user's
authenticationMechanismholds their password hash, or a bot's token. It was copied into places other users can read:GET /v1/eventsreturns it; an admin'sPUT /v1/userson a bot stores its decrypted JWT.GET /v1/users/{id}/versions,/versions/{v}and/v1/users/historyreturn old versions as stored, to anyone who may view a user.authenticationMechanismwas not marked"mask": true, and some writers skipped masking altogether (for exampleUserUtil, at every startup).This PR:
authenticationMechanismwith"mask": trueinside its definition inuser.json. Beside a$refthe generator ignores it.ChangeEventDAO.insertandinsertBatch, through the newChangeEventMasking. The raw SQL methods are renamedinsertMaskedRow(s). Callers do not change.authenticationMechanism), when stored and on every read, older rows included. A field that only holds secrets inside, such as a service connection, stays; its resource masks them per caller.MaskedFieldsreads the schema flag for events and history alike.Stored users are unchanged, so logins and bot tokens work.
Migration (2.0.7)
Plain SQL in the 2.0.7
postDataMigrationSQLScript.sql, with fixed names, removesauthenticationMechanismfrom stored user change events, the audit log, alert delivery records and user versions. SQL in 2.0.7 also runs on a database already at a 2.1.0 build, which skips 2.0.7 Java steps. No Java involved.Type of change:
Tests:
Unit tests
ChangeEventMaskingTest: a bot's token leaves an event, whether its entity is an object or a string.MaskedFieldsTest: users hide their credentials as a whole; services keep their connection.Backend integration tests
UserSecretsIT:GET /v1/events);mainand pass here, on MySQL and Postgres.Also checked by upgrading a real 2.0.6 database (MySQL and Postgres) through
migrate: the same result as the earlier Java version, row for row; a second run changes nothing; a database already at 2.1.0 is cleaned too. Logins and bot tokens still work.Ingestion integration tests
Playwright (UI) tests
UI screen recording / screenshots:
Not applicable.
Checklist:
The upgrade cleanup is addressed, but the two outstanding test requirements must be satisfied before merging.
Findings
Summary
The PR keeps user credentials out of new change events and user version history.
Reviews (5) · Last reviewed commit: "fix: run the user secrets cleanup as pla..." · Reviewed by Greptile