Summary
retentionPeriod is accepted as a JSON number of nanoseconds across the database tools (create_database, update_database) for all product types. JavaScript numbers are IEEE-754 doubles, so integers are exact only up to Number.MAX_SAFE_INTEGER (2^53 − 1 ≈ 9.007e15). Nanosecond retention values exceed that range at roughly 104 days, so longer retention periods can lose precision.
Details
- 1 day =
86_400 * 1e9 = 8.64e13 ns
Number.MAX_SAFE_INTEGER / 8.64e13 ≈ 104 days
- Example: 1 year =
3.1536e16 ns ≈ 3.5 × MAX_SAFE_INTEGER — not exactly representable.
Affected (all take retentionPeriod as ns-number):
src/tools/categories/database.tools.ts — inputSchema/zodSchema type number
src/services/database-management.service.ts — Cloud Dedicated/Clustered (payload.retentionPeriod), Cloud Serverless (everySeconds from ns), Core/Enterprise (formatRetentionPeriod ns → duration string)
Practical impact: a retention longer than ~104 days may be off by a small amount. For Core/Enterprise specifically, formatRetentionPeriod's hours % 24 === 0 check can fail on an already-imprecise large value and fall back to ${Math.floor(hours)}h, dropping up to an hour.
Suggested fix
Change the retentionPeriod contract to avoid ns-as-number. Options, in rough order of preference:
- Accept a humantime duration string (e.g.
"1y", "90d") — matches the InfluxDB CLI/API and removes the precision problem entirely.
- Accept seconds instead of nanoseconds (pushes the safe boundary out ~285 years).
- Accept the ns value as a string and parse server-side.
This is a cross-cutting change to the tool parameter contract for all product types, so it was intentionally left out of #59 (which adds Core/Enterprise retention support).
Context
Found while reviewing #56 / #59. The new unit tests deliberately use periods under the 104-day safe boundary (7d, 60d) to avoid the imprecision.
Priority: high — silent precision loss on a data-retention setting.
Summary
retentionPeriodis accepted as a JSONnumberof nanoseconds across the database tools (create_database,update_database) for all product types. JavaScript numbers are IEEE-754 doubles, so integers are exact only up toNumber.MAX_SAFE_INTEGER(2^53 − 1 ≈9.007e15). Nanosecond retention values exceed that range at roughly 104 days, so longer retention periods can lose precision.Details
86_400 * 1e9=8.64e13nsNumber.MAX_SAFE_INTEGER / 8.64e13≈ 104 days3.1536e16ns ≈ 3.5 ×MAX_SAFE_INTEGER— not exactly representable.Affected (all take
retentionPeriodas ns-number):src/tools/categories/database.tools.ts—inputSchema/zodSchematypenumbersrc/services/database-management.service.ts— Cloud Dedicated/Clustered (payload.retentionPeriod), Cloud Serverless (everySecondsfrom ns), Core/Enterprise (formatRetentionPeriodns → duration string)Practical impact: a retention longer than ~104 days may be off by a small amount. For Core/Enterprise specifically,
formatRetentionPeriod'shours % 24 === 0check can fail on an already-imprecise large value and fall back to${Math.floor(hours)}h, dropping up to an hour.Suggested fix
Change the
retentionPeriodcontract to avoid ns-as-number. Options, in rough order of preference:"1y","90d") — matches the InfluxDB CLI/API and removes the precision problem entirely.This is a cross-cutting change to the tool parameter contract for all product types, so it was intentionally left out of #59 (which adds Core/Enterprise retention support).
Context
Found while reviewing #56 / #59. The new unit tests deliberately use periods under the 104-day safe boundary (7d, 60d) to avoid the imprecision.
Priority: high — silent precision loss on a data-retention setting.