SymDB: Stop defaulting empty/nil env and version to 'none' in ServiceVersion#5694
Conversation
…Version ServiceVersion previously rewrote +env+ and +version+ inputs: @env = env.to_s.empty? ? 'none' : env.to_s @Version = version.to_s.empty? ? 'none' : version.to_s Drops the rewriting — both fields now pass through unchanged. Empty strings stay empty strings; nil stays nil. ServiceVersion's role is to wrap a payload, not to sanitize inputs; defaulting belongs at the caller (Component) where the source of env/version is known and the sentinel choice (if any) can be made deliberately. Master has no non-test callers of +ServiceVersion.new+ (verified via +grep -rn 'ServiceVersion.new' lib/+ — no matches), so this is contained to the spec changes in this PR. The four +converts ... to "none"+ tests are replaced with four +passes ... through unchanged+ tests covering the same nil/empty inputs, asserting on the new pass-through behavior. The two +to_h+ tests for +none+ defaulting are similarly replaced. Extracted from #5431 to land the behavior change independently of the broader symbol-database upload work. Note on pre-existing failure: +to_json produces valid JSON for complete Ruby payload+ (line 142) was already failing on master with +NameError: uninitialized constant Datadog::SymbolDatabase::Symbol+ — the spec file is missing +require 'datadog/symbol_database/symbol'+. Out of scope for this PR; not addressed here. Verification: - bundle exec rspec spec/datadog/symbol_database/service_version_spec.rb → 14 pass, 1 fail (the pre-existing failure described above) - bundle exec steep check lib/datadog/symbol_database/service_version.rb → No type error detected. - bundle exec rake standard → clean Co-Authored-By: Claude <[email protected]>
The test +to_json produces valid JSON for complete Ruby payload+ constructs +Datadog::SymbolDatabase::Symbol.new(...)+ but the spec file was missing +require 'datadog/symbol_database/symbol'+. The test was failing on master with: NameError: uninitialized constant Datadog::SymbolDatabase::Symbol Add the missing require. The spec is already in this PR's diff for the +none+ defaulting changes, so addressing the failure here keeps this branch's CI green. Flagged as out-of-scope in the original PR body — that was hand-waving; the fix is trivial and the file is already being modified. Verification: - bundle exec rspec spec/datadog/symbol_database/service_version_spec.rb → 15 examples, 0 failures (up from 14/15) Co-Authored-By: Claude <[email protected]>
🎉 All green!❄️ No new flaky tests detected 🎯 Code Coverage (details) 🔗 Commit SHA: 632beaf | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-05-06 19:59:32 Comparing candidate commit bcad13a in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 45 metrics, 1 unstable metrics.
|
What does this PR do?
Drops the empty/nil →
"none"rewriting ofenvandversioninDatadog::SymbolDatabase::ServiceVersion#initialize. Both fields now pass through unchanged.Before:
After:
ServiceVersion's role is to wrap a payload, not to sanitize inputs; defaulting belongs at the caller (Component) where the source of env/version is known and the sentinel choice (if any) can be made deliberately.
Master has no non-test callers of
ServiceVersion.new(verified viagrep -rn 'ServiceVersion.new' lib/— no matches), so this is contained to the spec changes in this PR.The four
converts ... to "none"tests are replaced with fourpasses ... through unchangedtests covering the same nil/empty inputs, asserting on the new pass-through behavior. The twoto_htests for"none"defaulting are similarly replaced.Motivation:
Extracted from #5431 to land the behavior change independently of the broader symbol-database upload work. ServiceVersion is currently only used by tests — no production callers exist on master.
Change log entry
None.
Note on pre-existing failure
to_json produces valid JSON for complete Ruby payload(line 142) was already failing on master withNameError: uninitialized constant Datadog::SymbolDatabase::Symbol— the spec file is missingrequire 'datadog/symbol_database/symbol'. This PR does not address it (out of scope).How to test the change?
Verification on this branch: 14 pass, 1 fail (the pre-existing failure described above).
bundle exec steep check lib/datadog/symbol_database/service_version.rb— No type error detectedbundle exec rake standard— clean