dd-trace 5.135.0 → 5.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/README.md +3 -0
  2. package/ci/cypress/support.js +2 -1
  3. package/ci/init.js +2 -22
  4. package/ci/vitest-no-worker-init-node-setup.mjs +2 -1
  5. package/ci/vitest-no-worker-init-runner-setup.mjs +2 -1
  6. package/ci/vitest-no-worker-init-setup.mjs +729 -724
  7. package/ci/vitest-no-worker-init-v5-setup.mjs +2 -1
  8. package/ext/exporters.js +0 -1
  9. package/index.d.ts +105 -5
  10. package/initialize.mjs +5 -2
  11. package/package.json +41 -36
  12. package/packages/datadog-esbuild/index.js +16 -70
  13. package/packages/datadog-esbuild/src/log.js +2 -29
  14. package/packages/datadog-instrumentations/src/ai.js +6 -1
  15. package/packages/datadog-instrumentations/src/aws-lambda.js +88 -0
  16. package/packages/datadog-instrumentations/src/cucumber.js +5 -2
  17. package/packages/datadog-instrumentations/src/cypress-config.js +20 -9
  18. package/packages/datadog-instrumentations/src/elevenlabs/activity.js +114 -0
  19. package/packages/datadog-instrumentations/src/elevenlabs/audio.js +104 -0
  20. package/packages/datadog-instrumentations/src/elevenlabs/index.js +288 -0
  21. package/packages/datadog-instrumentations/src/elevenlabs/session.js +444 -0
  22. package/packages/datadog-instrumentations/src/graphql.js +20 -17
  23. package/packages/datadog-instrumentations/src/helpers/bundler-esm-exports.js +582 -0
  24. package/packages/datadog-instrumentations/src/helpers/bundler-log.js +38 -0
  25. package/packages/datadog-instrumentations/src/helpers/bundler-transform.js +576 -0
  26. package/packages/datadog-instrumentations/src/helpers/bundler-utils.js +104 -0
  27. package/packages/datadog-instrumentations/src/helpers/fetch.js +51 -6
  28. package/packages/datadog-instrumentations/src/helpers/hook.js +29 -1
  29. package/packages/datadog-instrumentations/src/helpers/hooks.js +3 -7
  30. package/packages/datadog-instrumentations/src/helpers/lambda-handler.js +189 -0
  31. package/packages/datadog-instrumentations/src/helpers/rewriter/index.js +8 -0
  32. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentation-registry.js +26 -1
  33. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/async-mutex.js +41 -0
  34. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/elevenlabs.js +25 -0
  35. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/graphql.js +0 -36
  36. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-client.js +30 -0
  37. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/modelcontextprotocol-server.js +23 -0
  38. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/next.js +61 -0
  39. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/openai-agents-realtime.js +23 -0
  40. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/postgres.js +33 -4
  41. package/packages/datadog-instrumentations/src/helpers/rewriter/instrumentations/trpc.js +148 -0
  42. package/packages/datadog-instrumentations/src/helpers/rewriter/target-patterns.json +80 -0
  43. package/packages/datadog-instrumentations/src/helpers/rewriter/targets.json +23 -3
  44. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms/postgres.js +122 -0
  45. package/packages/datadog-instrumentations/src/helpers/rewriter/transforms.js +59 -2
  46. package/packages/datadog-instrumentations/src/ioredis.js +101 -3
  47. package/packages/datadog-instrumentations/src/microgateway-core.js +1 -2
  48. package/packages/datadog-instrumentations/src/modelcontextprotocol-client.js +21 -0
  49. package/packages/datadog-instrumentations/src/modelcontextprotocol-sdk.js +7 -1
  50. package/packages/datadog-instrumentations/src/modelcontextprotocol-server.js +41 -0
  51. package/packages/datadog-instrumentations/src/next.js +203 -26
  52. package/packages/datadog-instrumentations/src/openai-agents-realtime.js +149 -0
  53. package/packages/datadog-instrumentations/src/openai-realtime/audio-accumulator.js +27 -0
  54. package/packages/datadog-instrumentations/src/openai-realtime/index.js +17 -6
  55. package/packages/datadog-instrumentations/src/openai-realtime/server-playback.js +887 -0
  56. package/packages/datadog-instrumentations/src/openai-realtime/session.js +150 -25
  57. package/packages/datadog-instrumentations/src/openai-realtime/turns.js +29 -2
  58. package/packages/datadog-instrumentations/src/otel-sdk-trace.js +11 -9
  59. package/packages/datadog-instrumentations/src/router.js +35 -12
  60. package/packages/datadog-instrumentations/src/vitest-main.js +10 -2
  61. package/packages/datadog-instrumentations/src/webdriverio.js +12 -12
  62. package/packages/datadog-plugin-async-mutex/src/index.js +50 -0
  63. package/packages/datadog-plugin-aws-lambda/src/arn.js +41 -0
  64. package/packages/datadog-plugin-aws-lambda/src/event-type-guards.js +170 -0
  65. package/packages/datadog-plugin-aws-lambda/src/index.js +106 -0
  66. package/packages/datadog-plugin-aws-lambda/src/trigger.js +339 -0
  67. package/packages/datadog-plugin-aws-sdk/src/services/dynamodb.js +7 -0
  68. package/packages/datadog-plugin-aws-sdk/src/services/kinesis.js +32 -10
  69. package/packages/datadog-plugin-aws-sdk/src/services/lambda.js +10 -1
  70. package/packages/datadog-plugin-aws-sdk/src/services/sqs.js +4 -0
  71. package/packages/datadog-plugin-aws-sdk/src/services/stepfunctions.js +3 -0
  72. package/packages/datadog-plugin-cypress/src/cypress-plugin.js +50 -13
  73. package/packages/datadog-plugin-cypress/src/support.mjs +1353 -0
  74. package/packages/datadog-plugin-elevenlabs/src/index.js +69 -0
  75. package/packages/datadog-plugin-express/src/code_origin.js +2 -2
  76. package/packages/datadog-plugin-fastify/src/code_origin.js +2 -2
  77. package/packages/datadog-plugin-google-cloud-pubsub/src/consumer.js +20 -7
  78. package/packages/datadog-plugin-google-cloud-pubsub/src/producer.js +21 -52
  79. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-push-subscription.js +11 -2
  80. package/packages/datadog-plugin-google-cloud-pubsub/src/pubsub-request-context.js +25 -4
  81. package/packages/datadog-plugin-google-cloud-pubsub/src/resource-names.js +24 -0
  82. package/packages/datadog-plugin-graphql/src/tools/transforms.js +1 -0
  83. package/packages/datadog-plugin-http/src/client.js +34 -10
  84. package/packages/datadog-plugin-http2/src/client.js +40 -14
  85. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/tracing.js +28 -2
  86. package/packages/datadog-plugin-modelcontextprotocol-sdk/src/utils.js +1 -0
  87. package/packages/datadog-plugin-mongodb-core/src/query.js +17 -1
  88. package/packages/datadog-plugin-next/src/index.js +112 -14
  89. package/packages/datadog-plugin-postgres/src/index.js +118 -41
  90. package/packages/datadog-plugin-prisma/src/datadog-tracing-helper.js +5 -3
  91. package/packages/datadog-plugin-supabase/src/supabase-auth-js-gotrueclient-getuser.js +18 -8
  92. package/packages/datadog-plugin-supabase/src/supabase-functions-js-functionsclient-invoke.js +49 -13
  93. package/packages/datadog-plugin-supabase/src/supabase-storage-js-handle-request.js +34 -9
  94. package/packages/datadog-plugin-trpc/src/index.js +15 -0
  95. package/packages/datadog-plugin-trpc/src/procedure.js +48 -0
  96. package/packages/datadog-plugin-trpc/src/request.js +81 -0
  97. package/packages/datadog-plugin-undici/src/index.js +22 -7
  98. package/packages/datadog-plugin-vitest/src/index.js +3 -2
  99. package/packages/datadog-plugin-ws/src/close.js +3 -5
  100. package/packages/datadog-plugin-ws/src/producer.js +1 -4
  101. package/packages/datadog-plugin-ws/src/receiver.js +3 -5
  102. package/packages/datadog-plugin-ws/src/server.js +44 -13
  103. package/packages/datadog-turbopack/index.js +4 -28
  104. package/packages/datadog-turbopack/src/loader.js +14 -452
  105. package/packages/datadog-vite/index.js +537 -0
  106. package/packages/datadog-vite/src/log.js +5 -0
  107. package/packages/datadog-webpack/index.js +3 -55
  108. package/packages/datadog-webpack/src/log.js +2 -29
  109. package/packages/dd-trace/src/aiguard/evaluation.js +62 -1
  110. package/packages/dd-trace/src/aiguard/index.js +1 -1
  111. package/packages/dd-trace/src/aiguard/integrations/index.js +6 -5
  112. package/packages/dd-trace/src/aiguard/sdk.js +8 -2
  113. package/packages/dd-trace/src/aiguard/tags.js +2 -0
  114. package/packages/dd-trace/src/appsec/blocking/index.js +21 -1
  115. package/packages/dd-trace/src/appsec/channels.js +7 -0
  116. package/packages/dd-trace/src/appsec/downstream_requests.js +105 -0
  117. package/packages/dd-trace/src/appsec/graphql.js +89 -7
  118. package/packages/dd-trace/src/appsec/handlers/auth.js +1 -3
  119. package/packages/dd-trace/src/appsec/handlers/http-request.js +60 -65
  120. package/packages/dd-trace/src/appsec/handlers/http-response.js +61 -7
  121. package/packages/dd-trace/src/appsec/handlers/payments.js +23 -27
  122. package/packages/dd-trace/src/appsec/index.js +6 -0
  123. package/packages/dd-trace/src/appsec/lambda.js +17 -17
  124. package/packages/dd-trace/src/appsec/rasp/command_injection.js +4 -4
  125. package/packages/dd-trace/src/appsec/rasp/index.js +8 -1
  126. package/packages/dd-trace/src/appsec/rasp/lfi.js +2 -2
  127. package/packages/dd-trace/src/appsec/rasp/sql_injection.js +7 -17
  128. package/packages/dd-trace/src/appsec/rasp/ssrf.js +80 -16
  129. package/packages/dd-trace/src/appsec/rasp/utils.js +33 -3
  130. package/packages/dd-trace/src/appsec/recommended.json +1358 -94
  131. package/packages/dd-trace/src/appsec/reporter.js +9 -0
  132. package/packages/dd-trace/src/appsec/sdk/set_user.js +3 -3
  133. package/packages/dd-trace/src/appsec/sdk/track_event.js +4 -4
  134. package/packages/dd-trace/src/appsec/sdk/user_blocking.js +1 -1
  135. package/packages/dd-trace/src/appsec/user_tracking.js +6 -8
  136. package/packages/dd-trace/src/appsec/waf/index.js +65 -6
  137. package/packages/dd-trace/src/appsec/waf/waf_context_wrapper.js +33 -38
  138. package/packages/dd-trace/src/appsec/waf/waf_manager.js +18 -2
  139. package/packages/dd-trace/src/before-exit.js +32 -0
  140. package/packages/dd-trace/src/bootstrap.js +5 -3
  141. package/packages/dd-trace/src/ci-visibility/early-flake-detection/get-known-tests.js +15 -2
  142. package/packages/dd-trace/src/ci-visibility/exporters/ci-visibility-exporter.js +12 -34
  143. package/packages/dd-trace/src/ci-visibility/exporters/git/git_metadata.js +41 -13
  144. package/packages/dd-trace/src/ci-visibility/exporters/request.js +2 -3
  145. package/packages/dd-trace/src/ci-visibility/intelligent-test-runner/get-skippable-suites.js +1 -2
  146. package/packages/dd-trace/src/ci-visibility/requests/get-library-configuration.js +1 -1
  147. package/packages/dd-trace/src/ci-visibility/telemetry.js +6 -0
  148. package/packages/dd-trace/src/ci-visibility/test-management/get-test-management-tests.js +1 -1
  149. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache-schema.js +9 -134
  150. package/packages/dd-trace/src/ci-visibility/test-optimization-http-cache.js +11 -156
  151. package/packages/dd-trace/src/config/config-types.d.ts +3 -0
  152. package/packages/dd-trace/src/config/defaults.js +5 -0
  153. package/packages/dd-trace/src/config/generated-config-types.d.ts +46 -4
  154. package/packages/dd-trace/src/config/index.js +63 -31
  155. package/packages/dd-trace/src/config/parsers.js +44 -0
  156. package/packages/dd-trace/src/config/remote-config-layers.js +38 -0
  157. package/packages/dd-trace/src/config/remote_config.js +2 -1
  158. package/packages/dd-trace/src/config/supported-configurations.json +172 -10
  159. package/packages/dd-trace/src/constants.js +1 -0
  160. package/packages/dd-trace/src/datastreams/fnv.js +27 -0
  161. package/packages/dd-trace/src/datastreams/pathway.js +113 -28
  162. package/packages/dd-trace/src/datastreams/processor.js +5 -4
  163. package/packages/dd-trace/src/debugger/config.js +1 -1
  164. package/packages/dd-trace/src/debugger/devtools_client/request-options.js +7 -9
  165. package/packages/dd-trace/src/debugger/devtools_client/send.js +1 -1
  166. package/packages/dd-trace/src/debugger/devtools_client/state.js +3 -1
  167. package/packages/dd-trace/src/debugger/devtools_client/tags.js +1 -1
  168. package/packages/dd-trace/src/debugger/index.js +2 -2
  169. package/packages/dd-trace/src/debugger/inspect-segment.js +3 -2
  170. package/packages/dd-trace/src/debugger/pause-duration-histogram.js +6 -2
  171. package/packages/dd-trace/src/debugger/probe_sampler.js +39 -17
  172. package/packages/dd-trace/src/debugger/unsupported-runtime.js +2 -0
  173. package/packages/dd-trace/src/exporter.js +0 -11
  174. package/packages/dd-trace/src/exporters/common/request.js +81 -48
  175. package/packages/dd-trace/src/exporters/common/retry.js +12 -7
  176. package/packages/dd-trace/src/exporters/common/url.js +1 -1
  177. package/packages/dd-trace/src/git_metadata.js +2 -1
  178. package/packages/dd-trace/src/id.js +1 -1
  179. package/packages/dd-trace/src/index.js +6 -3
  180. package/packages/dd-trace/src/lambda/facade.js +75 -0
  181. package/packages/dd-trace/src/lambda/handler.js +3 -41
  182. package/packages/dd-trace/src/lambda/index.js +38 -15
  183. package/packages/dd-trace/src/lambda/runtime/patch.js +19 -3
  184. package/packages/dd-trace/src/lambda/wrap.js +44 -0
  185. package/packages/dd-trace/src/llmobs/constants/tags.js +2 -0
  186. package/packages/dd-trace/src/llmobs/experiments/experiment.js +10 -5
  187. package/packages/dd-trace/src/llmobs/plugins/elevenlabs.js +96 -0
  188. package/packages/dd-trace/src/llmobs/plugins/genai/util.js +19 -6
  189. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/index.js +54 -3
  190. package/packages/dd-trace/src/llmobs/plugins/modelcontextprotocol-sdk/utils.js +81 -1
  191. package/packages/dd-trace/src/llmobs/plugins/openai/realtime.js +38 -11
  192. package/packages/dd-trace/src/llmobs/plugins/vertexai.js +10 -2
  193. package/packages/dd-trace/src/llmobs/sdk.js +19 -0
  194. package/packages/dd-trace/src/llmobs/span_processor.js +9 -0
  195. package/packages/dd-trace/src/llmobs/tagger.js +22 -0
  196. package/packages/dd-trace/src/log/channels.js +4 -0
  197. package/packages/dd-trace/src/log/writer.js +6 -1
  198. package/packages/dd-trace/src/openfeature/agentless_configuration_source.js +7 -0
  199. package/packages/dd-trace/src/openfeature/configuration_source.js +55 -27
  200. package/packages/dd-trace/src/openfeature/flag-selection.js +152 -0
  201. package/packages/dd-trace/src/openfeature/flagging_provider.js +19 -1
  202. package/packages/dd-trace/src/openfeature/writers/base.js +1 -3
  203. package/packages/dd-trace/src/opentelemetry/logs/index.js +11 -0
  204. package/packages/dd-trace/src/opentelemetry/logs/otlp_http_log_exporter.js +1 -1
  205. package/packages/dd-trace/src/opentelemetry/metrics/index.js +7 -1
  206. package/packages/dd-trace/src/opentelemetry/metrics/otlp_http_metric_exporter.js +1 -1
  207. package/packages/dd-trace/src/opentelemetry/metrics/otlp_span_stats_exporter.js +4 -1
  208. package/packages/dd-trace/src/opentelemetry/otlp/otlp_http_exporter_base.js +19 -1
  209. package/packages/dd-trace/src/opentelemetry/span-ending-hook.js +5 -1
  210. package/packages/dd-trace/src/opentelemetry/span-helpers.js +6 -1
  211. package/packages/dd-trace/src/opentelemetry/span.js +2 -2
  212. package/packages/dd-trace/src/opentelemetry/startup-config.js +174 -0
  213. package/packages/dd-trace/src/opentelemetry/trace/otlp_http_trace_exporter.js +1 -1
  214. package/packages/dd-trace/src/opentelemetry/trace/otlp_transformer.js +7 -1
  215. package/packages/dd-trace/src/opentracing/propagation/tracestate.js +77 -23
  216. package/packages/dd-trace/src/opentracing/tracer.js +24 -0
  217. package/packages/dd-trace/src/otel-thread-ctx.js +28 -31
  218. package/packages/dd-trace/src/plugin_manager.js +34 -7
  219. package/packages/dd-trace/src/plugins/ci_plugin.js +143 -17
  220. package/packages/dd-trace/src/plugins/index.js +8 -0
  221. package/packages/dd-trace/src/plugins/plugin.js +4 -2
  222. package/packages/dd-trace/src/plugins/tracing.js +1 -1
  223. package/packages/dd-trace/src/plugins/util/ci.js +52 -1
  224. package/packages/dd-trace/src/plugins/util/git-cache.js +4 -4
  225. package/packages/dd-trace/src/plugins/util/git.js +263 -82
  226. package/packages/dd-trace/src/plugins/util/http-otel-semantics.js +80 -56
  227. package/packages/dd-trace/src/plugins/util/inferred_proxy.js +12 -4
  228. package/packages/dd-trace/src/plugins/util/status-validator.js +23 -10
  229. package/packages/dd-trace/src/plugins/util/tags.js +6 -0
  230. package/packages/dd-trace/src/plugins/util/test.js +92 -40
  231. package/packages/dd-trace/src/plugins/util/url.js +18 -7
  232. package/packages/dd-trace/src/plugins/util/user-provided-git.js +6 -6
  233. package/packages/dd-trace/src/plugins/util/web.js +65 -10
  234. package/packages/dd-trace/src/process-tags/index.js +1 -1
  235. package/packages/dd-trace/src/profiler.js +74 -12
  236. package/packages/dd-trace/src/profiling/profiler.js +30 -2
  237. package/packages/dd-trace/src/profiling/profilers/space.js +3 -1
  238. package/packages/dd-trace/src/profiling/profilers/wall.js +4 -4
  239. package/packages/dd-trace/src/profiling/remote-config.js +354 -0
  240. package/packages/dd-trace/src/profiling/runtime-capabilities.js +11 -0
  241. package/packages/dd-trace/src/profiling/webspan-utils.js +6 -5
  242. package/packages/dd-trace/src/propagation-hash/index.js +7 -0
  243. package/packages/dd-trace/src/proxy.js +46 -54
  244. package/packages/dd-trace/src/span_processor.js +20 -0
  245. package/packages/dd-trace/src/startup-log.js +8 -6
  246. package/packages/dd-trace/src/telemetry/metrics.js +2 -1
  247. package/packages/dd-trace/src/tracer.js +0 -2
  248. package/packages/dd-trace/src/web-tags-cache.js +8 -9
  249. package/register.js +2 -1
  250. package/vendor/dist/@apm-js-collab/code-transformer/LICENSE +489 -0
  251. package/vendor/dist/@datadog/flagging-core/LICENSE +221 -0
  252. package/vendor/dist/@datadog/flagging-core/index.js +1 -0
  253. package/vendor/dist/@datadog/openfeature-node-server/LICENSE +21 -1
  254. package/vendor/dist/@datadog/openfeature-node-server/rules-based/LICENSE +3 -1
  255. package/vendor/dist/@datadog/sketches-js/LICENSE +263 -0
  256. package/vendor/dist/@datadog/source-map/LICENSE +1 -0
  257. package/vendor/dist/@isaacs/ttlcache/LICENSE +13 -0
  258. package/vendor/dist/@opentelemetry/core/LICENSE +220 -1
  259. package/vendor/dist/@opentelemetry/core/index.js +1 -1
  260. package/vendor/dist/crypto-randomuuid/LICENSE +3 -0
  261. package/vendor/dist/escape-string-regexp/LICENSE +13 -0
  262. package/vendor/dist/esquery/LICENSE +2 -0
  263. package/vendor/dist/https-proxy-agent/LICENSE +80 -1
  264. package/vendor/dist/istanbul-lib-coverage/LICENSE +2 -0
  265. package/vendor/dist/jest-docblock/LICENSE +16 -0
  266. package/vendor/dist/jsonpath-plus/LICENSE +13 -0
  267. package/vendor/dist/limiter/LICENSE +2 -0
  268. package/vendor/dist/lodash.sortby/LICENSE +2 -0
  269. package/vendor/dist/lru-cache/LICENSE +13 -0
  270. package/vendor/dist/meriyah/LICENSE +13 -0
  271. package/vendor/dist/module-details-from-path/LICENSE +2 -0
  272. package/vendor/dist/mutexify/promise/LICENSE +28 -0
  273. package/vendor/dist/pprof-format/LICENSE +13 -0
  274. package/vendor/dist/pprof-format/index.js +1 -1
  275. package/vendor/dist/protobufjs/LICENSE +219 -0
  276. package/vendor/dist/protobufjs/minimal/LICENSE +219 -0
  277. package/vendor/dist/proxy-from-env/LICENSE +13 -0
  278. package/vendor/dist/retry/LICENSE +2 -0
  279. package/vendor/dist/rfdc/LICENSE +2 -0
  280. package/vendor/dist/semifies/LICENSE +3 -1
  281. package/vendor/dist/shell-quote/LICENSE +3 -1
  282. package/vendor/dist/source-map/LICENSE +1 -0
  283. package/vendor/dist/source-map/lib/util/LICENSE +1 -0
  284. package/vendor/dist/tlhunter-sorted-set/LICENSE +2 -0
  285. package/vendor/dist/ttl-set/LICENSE +28 -0
  286. package/vite.d.ts +7 -0
  287. package/vite.js +3 -0
  288. package/ci/diagnose.js +0 -2215
  289. package/ci/runbook.md +0 -299
  290. package/ci/test-optimization-validation/approval-artifacts.js +0 -175
  291. package/ci/test-optimization-validation/approval.js +0 -386
  292. package/ci/test-optimization-validation/artifact-id.js +0 -18
  293. package/ci/test-optimization-validation/blocker-category.js +0 -24
  294. package/ci/test-optimization-validation/bounded-json.js +0 -120
  295. package/ci/test-optimization-validation/ci-command-candidate.js +0 -77
  296. package/ci/test-optimization-validation/ci-discovery.js +0 -192
  297. package/ci/test-optimization-validation/ci-package-scripts.js +0 -169
  298. package/ci/test-optimization-validation/ci-remediation.js +0 -283
  299. package/ci/test-optimization-validation/cli.js +0 -954
  300. package/ci/test-optimization-validation/command-blocker.js +0 -377
  301. package/ci/test-optimization-validation/command-output-policy.js +0 -188
  302. package/ci/test-optimization-validation/command-runner.js +0 -649
  303. package/ci/test-optimization-validation/environment.js +0 -88
  304. package/ci/test-optimization-validation/executable-approval.js +0 -47
  305. package/ci/test-optimization-validation/executable.js +0 -244
  306. package/ci/test-optimization-validation/execution-lock.js +0 -70
  307. package/ci/test-optimization-validation/framework-adapters/cucumber-validation.json +0 -3
  308. package/ci/test-optimization-validation/framework-adapters/cucumber.js +0 -767
  309. package/ci/test-optimization-validation/framework-adapters/cypress.js +0 -99
  310. package/ci/test-optimization-validation/framework-adapters/playwright.js +0 -175
  311. package/ci/test-optimization-validation/framework-adapters/vitest.js +0 -513
  312. package/ci/test-optimization-validation/generated-file-policy.js +0 -63
  313. package/ci/test-optimization-validation/generated-files.js +0 -425
  314. package/ci/test-optimization-validation/generated-test-contract.js +0 -284
  315. package/ci/test-optimization-validation/generated-verifier.js +0 -235
  316. package/ci/test-optimization-validation/literal-environment.js +0 -56
  317. package/ci/test-optimization-validation/literal-glob.js +0 -52
  318. package/ci/test-optimization-validation/manifest-loader.js +0 -116
  319. package/ci/test-optimization-validation/manifest-scaffold.js +0 -1276
  320. package/ci/test-optimization-validation/manifest-schema.js +0 -695
  321. package/ci/test-optimization-validation/offline-fixtures.js +0 -335
  322. package/ci/test-optimization-validation/offline-output.js +0 -406
  323. package/ci/test-optimization-validation/package-check.js +0 -97
  324. package/ci/test-optimization-validation/payload-normalizer.js +0 -72
  325. package/ci/test-optimization-validation/plan-writer.js +0 -541
  326. package/ci/test-optimization-validation/preflight-runner.js +0 -186
  327. package/ci/test-optimization-validation/project-build-artifact.js +0 -31
  328. package/ci/test-optimization-validation/redaction.js +0 -319
  329. package/ci/test-optimization-validation/report-writer.js +0 -666
  330. package/ci/test-optimization-validation/result-semantics.js +0 -103
  331. package/ci/test-optimization-validation/runner-command.js +0 -264
  332. package/ci/test-optimization-validation/runner-contract.js +0 -695
  333. package/ci/test-optimization-validation/safe-files.js +0 -202
  334. package/ci/test-optimization-validation/scenarios/auto-test-retries.js +0 -171
  335. package/ci/test-optimization-validation/scenarios/basic-reporting.js +0 -407
  336. package/ci/test-optimization-validation/scenarios/ci-wiring.js +0 -666
  337. package/ci/test-optimization-validation/scenarios/early-flake-detection.js +0 -142
  338. package/ci/test-optimization-validation/scenarios/helpers.js +0 -621
  339. package/ci/test-optimization-validation/scenarios/test-management.js +0 -219
  340. package/ci/test-optimization-validation/source-text.js +0 -84
  341. package/ci/test-optimization-validation/static-diagnosis.js +0 -166
  342. package/ci/test-optimization-validation/test-output.js +0 -120
  343. package/ci/test-optimization-validation/validation-blocker.js +0 -21
  344. package/ci/validate-test-optimization.js +0 -3
  345. package/packages/datadog-esbuild/src/resolver.js +0 -284
  346. package/packages/datadog-esbuild/src/utils.js +0 -318
  347. package/packages/datadog-plugin-cypress/src/support.js +0 -1348
  348. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/index.js +0 -156
  349. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/msgpack-to-json.js +0 -287
  350. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/payload-projection.js +0 -84
  351. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/sink.js +0 -368
  352. package/packages/dd-trace/src/ci-visibility/exporters/ci-validation/writer.js +0 -59
@@ -10,6 +10,8 @@ const FormData = require('../../../exporters/common/form-data')
10
10
  const request = require('../../../exporters/common/request')
11
11
 
12
12
  const log = require('../../../log')
13
+ const { validateGitRepositoryUrl, validateGitCommitSha } = require('../../../plugins/util/user-provided-git')
14
+ const { filterSensitiveInfoFromRepository } = require('../../../plugins/util/url')
13
15
  const { getSegment } = require('../../../util')
14
16
  const {
15
17
  getLatestCommits,
@@ -18,6 +20,7 @@ const {
18
20
  getCommitsRevList,
19
21
  isShallowRepository,
20
22
  unshallowRepository,
23
+ fetchHeadCommitSha,
21
24
  isGitAvailable,
22
25
  } = require('../../../plugins/util/git')
23
26
 
@@ -35,7 +38,7 @@ const {
35
38
  } = require('../../../ci-visibility/telemetry')
36
39
 
37
40
  /** @typedef {{ isEvpProxy: boolean, evpProxyPrefix: string }} EvpProxyConfiguration */
38
- /** @typedef {EvpProxyConfiguration & { url: URL, repositoryUrl: string }} GitUploadTarget */
41
+ /** @typedef {EvpProxyConfiguration & { url: URL, repositoryUrl: string, gitRoot?: string }} GitUploadTarget */
39
42
 
40
43
  const isValidSha1 = (sha) => /^[0-9a-f]{40}$/.test(sha)
41
44
  const isValidSha256 = (sha) => /^[0-9a-f]{64}$/.test(sha)
@@ -71,7 +74,7 @@ function getCommonRequestOptions (url) {
71
74
  * @param {GitUploadTarget & { latestCommits: string[] }} options
72
75
  * @param {(error: Error | null, commitsToUpload?: string[]) => void} callback
73
76
  */
74
- function getCommitsToUpload ({ url, repositoryUrl, latestCommits, isEvpProxy, evpProxyPrefix }, callback) {
77
+ function getCommitsToUpload ({ url, repositoryUrl, latestCommits, isEvpProxy, evpProxyPrefix, gitRoot }, callback) {
75
78
  const commonOptions = getCommonRequestOptions(url)
76
79
 
77
80
  const options = {
@@ -123,7 +126,11 @@ function getCommitsToUpload ({ url, repositoryUrl, latestCommits, isEvpProxy, ev
123
126
  return callback(null, [])
124
127
  }
125
128
 
126
- const commitsToUpload = getCommitsRevList(alreadySeenCommits, commitsToInclude)
129
+ let commitsToUpload = getCommitsRevList(alreadySeenCommits, commitsToInclude, false, gitRoot)
130
+ // Partial clones may need promised trees; only hydrate them when recovery is enabled, with a bounded retry.
131
+ if (commitsToUpload === null && getConfig().testOptimization.DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED) {
132
+ commitsToUpload = getCommitsRevList(alreadySeenCommits, commitsToInclude, true, gitRoot)
133
+ }
127
134
 
128
135
  if (commitsToUpload === null) {
129
136
  return callback(new Error('git rev-list failed'))
@@ -207,10 +214,11 @@ function generateAndUploadPackFiles ({
207
214
  commitsToUpload,
208
215
  repositoryUrl,
209
216
  headCommit,
217
+ gitRoot,
210
218
  }, callback) {
211
219
  log.debug('There are %s commits to upload', commitsToUpload.length)
212
220
 
213
- const packFilesToUpload = generatePackFilesForCommits(commitsToUpload)
221
+ const packFilesToUpload = generatePackFilesForCommits(commitsToUpload, gitRoot)
214
222
 
215
223
  log.debug('Uploading %s packfiles.', packFilesToUpload.length)
216
224
 
@@ -261,23 +269,40 @@ function generateAndUploadPackFiles ({
261
269
  * @param {EvpProxyConfiguration} evpProxyConfiguration
262
270
  * @param {string | undefined} configRepositoryUrl repository URL from the configuration, if set
263
271
  * @param {(error?: Error | null) => void} callback
272
+ * @param {string=} configCommitSha
273
+ * @param {string=} gitRoot
264
274
  */
265
- function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryUrl, callback) {
275
+ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryUrl, callback,
276
+ configCommitSha, gitRoot = process.cwd()) {
266
277
  if (!isGitAvailable()) {
267
278
  return callback(new Error('Git is not available'))
268
279
  }
269
280
  let repositoryUrl = configRepositoryUrl
270
281
  if (!repositoryUrl) {
271
- repositoryUrl = getRepositoryUrl()
282
+ repositoryUrl = getRepositoryUrl(gitRoot)
272
283
  }
273
284
 
285
+ repositoryUrl = filterSensitiveInfoFromRepository(repositoryUrl)
274
286
  log.debug('Uploading git history for repository', repositoryUrl)
275
287
 
276
- if (!repositoryUrl) {
288
+ if (!repositoryUrl || !validateGitRepositoryUrl(repositoryUrl)) {
277
289
  return callback(new Error('Repository URL is empty'))
278
290
  }
279
291
 
280
- let latestCommits = getLatestCommits()
292
+ let latestCommits = getLatestCommits(configCommitSha, gitRoot)
293
+ let recoveredSelectedCommit = false
294
+ if (!latestCommits.length && getConfig().testOptimization.DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED &&
295
+ validateGitCommitSha(configCommitSha)) {
296
+ if (isShallowRepository(true, gitRoot)) unshallowRepository(false, configCommitSha, gitRoot)
297
+ else fetchHeadCommitSha(configCommitSha, false, gitRoot)
298
+ latestCommits = getLatestCommits(configCommitSha, gitRoot)
299
+ recoveredSelectedCommit = true
300
+ }
301
+ if (!latestCommits.length) {
302
+ return callback(Object.assign(new Error('Selected Git commit is unavailable'), {
303
+ code: 'ERR_GIT_COMMIT_UNAVAILABLE',
304
+ }))
305
+ }
281
306
  log.debug('There were %s commits since last month.', latestCommits.length)
282
307
 
283
308
  const getOnFinishGetCommitsToUpload = (hasCheckedShallow) => (err, commitsToUpload) => {
@@ -291,8 +316,8 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
291
316
  }
292
317
 
293
318
  // If it has already unshallowed or the clone is not shallow, we move on
294
- if (hasCheckedShallow || !isShallowRepository()) {
295
- const [headCommit] = latestCommits
319
+ if (hasCheckedShallow || !isShallowRepository(false, gitRoot)) {
320
+ const headCommit = configCommitSha || latestCommits[0]
296
321
  return generateAndUploadPackFiles({
297
322
  url,
298
323
  isEvpProxy,
@@ -300,22 +325,24 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
300
325
  commitsToUpload,
301
326
  repositoryUrl,
302
327
  headCommit,
328
+ gitRoot,
303
329
  }, callback)
304
330
  }
305
331
  // Otherwise we unshallow and get commits to upload again
306
332
  log.debug('It is shallow clone, unshallowing...')
307
333
  if (getConfig().testOptimization.DD_CIVISIBILITY_GIT_UNSHALLOW_ENABLED) {
308
- unshallowRepository(false)
334
+ unshallowRepository(false, configCommitSha, gitRoot)
309
335
  }
310
336
 
311
337
  // The latest commits change after unshallowing
312
- latestCommits = getLatestCommits()
338
+ latestCommits = getLatestCommits(configCommitSha, gitRoot)
313
339
  getCommitsToUpload({
314
340
  url,
315
341
  repositoryUrl,
316
342
  latestCommits,
317
343
  isEvpProxy,
318
344
  evpProxyPrefix,
345
+ gitRoot,
319
346
  }, getOnFinishGetCommitsToUpload(true))
320
347
  }
321
348
 
@@ -325,7 +352,8 @@ function sendGitMetadata (url, { isEvpProxy, evpProxyPrefix }, configRepositoryU
325
352
  latestCommits,
326
353
  isEvpProxy,
327
354
  evpProxyPrefix,
328
- }, getOnFinishGetCommitsToUpload(false))
355
+ gitRoot,
356
+ }, getOnFinishGetCommitsToUpload(recoveredSelectedCommit))
329
357
  }
330
358
 
331
359
  module.exports = {
@@ -430,13 +430,12 @@ function requestBuffered (data, options, callback, reservedPayloadSize) {
430
430
  (attemptTimedOut || isRetriableNetworkError(error) || isUnknownNetworkError ||
431
431
  isRetriableHttpStatusCode(responseStatus))
432
432
  const retryUntilDeadline = options.deadline !== undefined && options.retryUntilDeadline !== false
433
- const reachedAttemptLimit = !retryUntilDeadline && attemptIndex >= getMaxAttempts(attemptOptions)
434
433
  const reachedUnknownNetworkAttemptLimit = isUnknownNetworkError && attemptIndex >= 2
435
434
  if (
436
435
  options.retry === false ||
437
436
  !isRetriableError ||
438
- reachedAttemptLimit ||
439
- reachedUnknownNetworkAttemptLimit
437
+ reachedUnknownNetworkAttemptLimit ||
438
+ (!retryUntilDeadline && attemptIndex >= getMaxAttempts(attemptOptions))
440
439
  ) {
441
440
  complete(requestError, result, statusCode, headers)
442
441
  return
@@ -28,12 +28,11 @@ function parseSkippableSuitesResponse (
28
28
  isCoverageReportUploadEnabled = false,
29
29
  isLineCoverageSupported = true,
30
30
  validateRequiredFields = false,
31
- validationMode = false,
32
31
  } = {}
33
32
  ) {
34
33
  const parsedResponse = parseJsonResponse(rawJson)
35
34
  if (validateRequiredFields) {
36
- validateSkippableTestsResponse(parsedResponse, { validationMode })
35
+ validateSkippableTestsResponse(parsedResponse)
37
36
  }
38
37
  let coverage
39
38
  const coverageByFilename = parsedResponse.meta?.coverage
@@ -155,7 +155,7 @@ function parseJsonResponse (rawJson) {
155
155
  function parseLibraryConfigurationResponse (rawJson, config = getConfig(), options = {}) {
156
156
  const parsedResponse = parseJsonResponse(rawJson)
157
157
  if (options.validateRequiredFields) {
158
- validateSettingsResponse(parsedResponse, options)
158
+ validateSettingsResponse(parsedResponse)
159
159
  }
160
160
  const parsedAttributes = parsedResponse?.data?.attributes ?? parsedResponse
161
161
  if (!isRecord(parsedAttributes)) {
@@ -133,6 +133,9 @@ const TELEMETRY_KNOWN_TESTS_MS = 'early_flake_detection.request_ms'
133
133
  const TELEMETRY_KNOWN_TESTS_ERRORS = 'early_flake_detection.request_errors'
134
134
  const TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS = 'early_flake_detection.response_tests'
135
135
  const TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES = 'early_flake_detection.response_bytes'
136
+ const TELEMETRY_KNOWN_TESTS_PAGES_FETCHED = 'known_tests.pages_fetched'
137
+ const TELEMETRY_KNOWN_TESTS_TOTAL_FETCH_MS = 'known_tests.total_fetch_ms'
138
+ const TELEMETRY_KNOWN_TESTS_TOTAL_REQUEST_MS = 'known_tests.total_request_ms'
136
139
  // coverage upload
137
140
  const TELEMETRY_COVERAGE_UPLOAD = 'coverage_upload.request'
138
141
  const TELEMETRY_COVERAGE_UPLOAD_MS = 'coverage_upload.request_ms'
@@ -207,6 +210,9 @@ module.exports = {
207
210
  TELEMETRY_KNOWN_TESTS_ERRORS,
208
211
  TELEMETRY_KNOWN_TESTS_RESPONSE_TESTS,
209
212
  TELEMETRY_KNOWN_TESTS_RESPONSE_BYTES,
213
+ TELEMETRY_KNOWN_TESTS_PAGES_FETCHED,
214
+ TELEMETRY_KNOWN_TESTS_TOTAL_FETCH_MS,
215
+ TELEMETRY_KNOWN_TESTS_TOTAL_REQUEST_MS,
210
216
  TELEMETRY_COVERAGE_UPLOAD,
211
217
  TELEMETRY_COVERAGE_UPLOAD_MS,
212
218
  TELEMETRY_COVERAGE_UPLOAD_ERRORS,
@@ -46,7 +46,7 @@ function parseJsonResponse (rawJson) {
46
46
  function parseTestManagementTestsResponse (rawJson, options = {}) {
47
47
  const parsedResponse = parseJsonResponse(rawJson)
48
48
  if (options.validateRequiredFields) {
49
- validateTestManagementTestsResponse(parsedResponse, options)
49
+ validateTestManagementTestsResponse(parsedResponse)
50
50
  }
51
51
  const { data: { attributes: { modules: testManagementTests } } } = parsedResponse
52
52
  return testManagementTests
@@ -13,25 +13,7 @@ const REQUIRED_SETTINGS_KEYS = [
13
13
  'impacted_tests_enabled',
14
14
  'coverage_report_upload_enabled',
15
15
  ]
16
- const SETTINGS_BOOLEAN_KEYS = [
17
- 'code_coverage',
18
- 'tests_skipping',
19
- 'itr_enabled',
20
- 'require_git',
21
- 'flaky_test_retries_enabled',
22
- 'di_enabled',
23
- 'known_tests_enabled',
24
- 'impacted_tests_enabled',
25
- 'coverage_report_upload_enabled',
26
- ]
27
- const EARLY_FLAKE_DETECTION_KEYS = ['enabled', 'faulty_session_threshold', 'slow_test_retries']
28
- const TEST_MANAGEMENT_KEYS = ['attempt_to_fix_retries', 'enabled']
29
- const RETRY_THRESHOLD_PATTERN = /^\d+(?:ms|[smh])$/
30
- const MAX_VALIDATION_MODULES = 1000
31
- const MAX_VALIDATION_SUITES = 10_000
32
- const MAX_VALIDATION_TESTS = 100_000
33
16
  const MAX_RETRIES = 100
34
- const MAX_VALIDATION_STRING_BYTES = 4096
35
17
 
36
18
  function isObject (value) {
37
19
  return value !== null && typeof value === 'object' && !Array.isArray(value)
@@ -57,7 +39,7 @@ function getAttributes (response, endpoint) {
57
39
  return attributes
58
40
  }
59
41
 
60
- function validateSettingsResponse (response, options = {}) {
42
+ function validateSettingsResponse (response) {
61
43
  const attributes = response?.data?.attributes ?? response
62
44
  assertObject(attributes, 'Invalid settings response: attributes must be an object')
63
45
  assertHasKeys(attributes, REQUIRED_SETTINGS_KEYS, 'settings')
@@ -65,26 +47,9 @@ function validateSettingsResponse (response, options = {}) {
65
47
  assertObject(attributes.test_management, 'Invalid settings response: test_management must be an object')
66
48
  assertHasKeys(attributes.early_flake_detection, ['enabled'], 'settings early_flake_detection')
67
49
  assertHasKeys(attributes.test_management, ['enabled'], 'settings test_management')
68
- if (!options.validationMode) return
69
-
70
- assertOnlyKeys(attributes, REQUIRED_SETTINGS_KEYS, 'settings')
71
- assertOnlyKeys(attributes.early_flake_detection, EARLY_FLAKE_DETECTION_KEYS, 'settings early_flake_detection')
72
- assertOnlyKeys(attributes.test_management, TEST_MANAGEMENT_KEYS, 'settings test_management')
73
- assertBooleanFields(attributes, SETTINGS_BOOLEAN_KEYS, 'settings')
74
- assertBooleanFields(attributes.early_flake_detection, ['enabled'], 'settings early_flake_detection')
75
- assertBooleanFields(attributes.test_management, ['enabled'], 'settings test_management')
76
- assertOptionalBoundedNumber(
77
- attributes.early_flake_detection.faulty_session_threshold,
78
- 'settings early_flake_detection faulty_session_threshold'
79
- )
80
- assertRetryMap(attributes.early_flake_detection.slow_test_retries)
81
- assertOptionalBoundedNumber(
82
- attributes.test_management.attempt_to_fix_retries,
83
- 'settings test_management attempt_to_fix_retries'
84
- )
85
50
  }
86
51
 
87
- function validateKnownTestsResponse (response, options = {}) {
52
+ function validateKnownTestsResponse (response) {
88
53
  const attributes = getAttributes(response, 'known tests')
89
54
  assertHasKeys(attributes, ['tests'], 'known tests')
90
55
 
@@ -92,46 +57,26 @@ function validateKnownTestsResponse (response, options = {}) {
92
57
  if (tests === null) return
93
58
  assertObject(tests, 'Invalid known tests response: tests must be an object or null')
94
59
 
95
- let suiteCount = 0
96
- let testCount = 0
97
- const modules = Object.entries(tests)
98
- if (options.validationMode && modules.length > MAX_VALIDATION_MODULES) {
99
- throw new Error('Invalid known tests response: too many modules')
100
- }
101
- for (const [moduleName, suites] of modules) {
102
- if (options.validationMode) assertValidationString(moduleName, 'known tests module')
60
+ for (const suites of Object.values(tests)) {
103
61
  assertObject(suites, 'Invalid known tests response: module suites must be objects')
104
- for (const [suiteName, testNames] of Object.entries(suites)) {
105
- suiteCount++
106
- if (options.validationMode) {
107
- if (suiteCount > MAX_VALIDATION_SUITES) throw new Error('Invalid known tests response: too many suites')
108
- assertValidationString(suiteName, 'known tests suite')
109
- }
62
+ for (const testNames of Object.values(suites)) {
110
63
  if (!Array.isArray(testNames)) {
111
64
  throw new TypeError('Invalid known tests response: suite tests must be arrays')
112
65
  }
113
66
  for (const testName of testNames) {
114
- testCount++
115
67
  if (typeof testName !== 'string') {
116
68
  throw new TypeError('Invalid known tests response: test names must be strings')
117
69
  }
118
- if (options.validationMode) {
119
- if (testCount > MAX_VALIDATION_TESTS) throw new Error('Invalid known tests response: too many tests')
120
- assertValidationString(testName, 'known test name')
121
- }
122
70
  }
123
71
  }
124
72
  }
125
73
  }
126
74
 
127
- function validateSkippableTestsResponse (response, options = {}) {
75
+ function validateSkippableTestsResponse (response) {
128
76
  assertObject(response, 'Invalid skippable tests response: response must be an object')
129
77
  if (!Array.isArray(response.data)) {
130
78
  throw new TypeError('Invalid skippable tests response: data must be an array')
131
79
  }
132
- if (options.validationMode && response.data.length > MAX_VALIDATION_TESTS) {
133
- throw new Error('Invalid skippable tests response: too many items')
134
- }
135
80
  if (response.meta !== undefined) {
136
81
  assertObject(response.meta, 'Invalid skippable tests response: meta must be an object')
137
82
  }
@@ -147,56 +92,28 @@ function validateSkippableTestsResponse (response, options = {}) {
147
92
  if (typeof item.type !== 'string') {
148
93
  throw new TypeError('Invalid skippable tests response: data entry type must be a string')
149
94
  }
150
- if (options.validationMode) assertValidationString(item.type, 'skippable test type')
151
95
  assertObject(item.attributes, 'Invalid skippable tests response: data entry attributes must be an object')
152
96
  if ((item.type === 'suite' || item.type === 'test') && typeof item.attributes.suite !== 'string') {
153
97
  throw new Error('Invalid skippable tests response: data entry suite must be a string')
154
98
  }
155
- if (options.validationMode && item.attributes.suite !== undefined) {
156
- assertValidationString(item.attributes.suite, 'skippable test suite')
157
- }
158
99
  if (item.type === 'test' && typeof item.attributes.name !== 'string') {
159
100
  throw new Error('Invalid skippable tests response: data entry name must be a string')
160
101
  }
161
- if (options.validationMode && item.attributes.name !== undefined) {
162
- assertValidationString(item.attributes.name, 'skippable test name')
163
- }
164
102
  }
165
103
  }
166
104
 
167
- function validateTestManagementTestsResponse (response, options = {}) {
105
+ function validateTestManagementTestsResponse (response) {
168
106
  const attributes = getAttributes(response, 'test management tests')
169
107
  assertHasKeys(attributes, ['modules'], 'test management tests')
170
108
  assertObject(attributes.modules, 'Invalid test management tests response: modules must be an object')
171
109
 
172
- let suiteCount = 0
173
- let testCount = 0
174
- const modules = Object.entries(attributes.modules)
175
- if (options.validationMode && modules.length > MAX_VALIDATION_MODULES) {
176
- throw new Error('Invalid test management tests response: too many modules')
177
- }
178
- for (const [moduleName, testModule] of modules) {
179
- if (options.validationMode) assertValidationString(moduleName, 'test management module')
110
+ for (const testModule of Object.values(attributes.modules)) {
180
111
  assertObject(testModule, 'Invalid test management tests response: modules entries must be objects')
181
112
  assertObject(testModule.suites, 'Invalid test management tests response: module suites must be objects')
182
- for (const [suiteName, suite] of Object.entries(testModule.suites)) {
183
- suiteCount++
184
- if (options.validationMode) {
185
- if (suiteCount > MAX_VALIDATION_SUITES) {
186
- throw new Error('Invalid test management tests response: too many suites')
187
- }
188
- assertValidationString(suiteName, 'test management suite')
189
- }
113
+ for (const suite of Object.values(testModule.suites)) {
190
114
  assertObject(suite, 'Invalid test management tests response: suites entries must be objects')
191
115
  assertObject(suite.tests, 'Invalid test management tests response: suite tests must be objects')
192
- for (const [testName, test] of Object.entries(suite.tests)) {
193
- testCount++
194
- if (options.validationMode) {
195
- if (testCount > MAX_VALIDATION_TESTS) {
196
- throw new Error('Invalid test management tests response: too many tests')
197
- }
198
- assertValidationString(testName, 'test management test')
199
- }
116
+ for (const test of Object.values(suite.tests)) {
200
117
  assertObject(test, 'Invalid test management tests response: tests entries must be objects')
201
118
  assertObject(test.properties, 'Invalid test management tests response: test properties must be objects')
202
119
  }
@@ -204,48 +121,6 @@ function validateTestManagementTestsResponse (response, options = {}) {
204
121
  }
205
122
  }
206
123
 
207
- function assertBooleanFields (object, keys, endpoint) {
208
- for (const key of keys) {
209
- if (typeof object[key] !== 'boolean') {
210
- throw new TypeError(`Invalid ${endpoint} response: ${key} must be a boolean`)
211
- }
212
- }
213
- }
214
-
215
- function assertOptionalBoundedNumber (value, endpoint) {
216
- if (value === undefined) return
217
- if (!Number.isFinite(value) || !Number.isInteger(value) || value < 0 || value > MAX_RETRIES) {
218
- throw new TypeError(`Invalid ${endpoint}: value must be between 0 and ${MAX_RETRIES}`)
219
- }
220
- }
221
-
222
- function assertRetryMap (retries) {
223
- if (retries === undefined) return
224
- assertObject(retries, 'Invalid settings response: early_flake_detection slow_test_retries must be an object')
225
- for (const [threshold, count] of Object.entries(retries)) {
226
- assertValidationString(threshold, 'early flake detection retry threshold')
227
- if (!RETRY_THRESHOLD_PATTERN.test(threshold)) {
228
- throw new TypeError('Invalid early flake detection retry threshold: expected a duration such as 5s')
229
- }
230
- assertOptionalBoundedNumber(count, `early flake detection retry count ${threshold}`)
231
- }
232
- }
233
-
234
- function assertOnlyKeys (object, keys, endpoint) {
235
- const allowed = new Set(keys)
236
- for (const key of Object.keys(object)) {
237
- if (!allowed.has(key)) {
238
- throw new Error(`Invalid ${endpoint} response: unexpected ${key}`)
239
- }
240
- }
241
- }
242
-
243
- function assertValidationString (value, field) {
244
- if (typeof value !== 'string' || Buffer.byteLength(value) > MAX_VALIDATION_STRING_BYTES) {
245
- throw new TypeError(`Invalid ${field}: value must be a bounded string`)
246
- }
247
- }
248
-
249
124
  module.exports = {
250
125
  MAX_RETRIES,
251
126
  validateKnownTestsResponse,