Absolute CI source paths silently drop 100,000-row insert batches from test_file_mappings

Background

The coverage exporter in gitlab_quality-test_tooling writes shared.test_file_mappings from gitlab-org/gitlab CI about every two hours. The table carries one CHECK constraint, valid_source_file_format, requiring source_file to be repo-relative.

CHECK (source_file NOT LIKE '/%') AND (source_file NOT LIKE './%')

I found this while verifying the read-back fix for #789 (closed). It is a separate defect from the four steps described there.

Problem

The exporter sends absolute CI build paths, so ClickHouse rejects them with Code 469. The constraint is evaluated per insert, so the whole 100,000-row batch containing the offending row is lost rather than just that row.

Code: 469. Constraint `valid_source_file_format` for table shared.test_file_mappings is violated
at row 1. Column values:
source_file = '/builds/gitlab-org/gitlab/app/assets/javascripts/tabs/constants.js'

Client#insert_json_data slices records into batches of 100,000, sends all of them, collects the results, and only then raises. The clean batches are already committed by then, so the run lands a partial export with no marker that anything is missing.

The surviving row counts show this directly. The 2026-09-03 16:06 run left exactly 200,000 rows, and two runs on 09-02 left exactly 300,000 each, while complete runs land arbitrary totals such as 11,567,802 on 08-28.

Nothing catches it before the insert. valid_source_file? tests only blank?, and sanitized_data_record passes source_file through unchanged. Two of the coverage jobs in .gitlab/ci/coverage.gitlab-ci.yml also invoke test-coverage with || true, so the raised error is discarded there.

Code 469 fired twice on 2026-09-03, at 12:10:32 and 14:27:21 UTC.

Proposed solution(s)

Normalize source_file in sanitized_data_record before inserting, stripping a leading ./ and the absolute CI build directory prefix so the value is repo-relative and satisfies the constraint.

Alternatives considered:

alternative why not
Drop records that violate the constraint Discards real coverage data for a path the exporter can repair
Make the batch insert atomic Worth doing, and it is why one bad row costs 100,000, but it is a larger change to the shared client and would not stop the rejection
Relax the constraint The repo-relative form is what the dashboards and materialized views join on