Repository navigation
chore(deps): replace humantime in the IC's own crates - #12383
basvandijk wants to merge 9 commits into
Conversation
humantime is unmaintained (RUSTSEC-2026-0542). Remove it from the IC's own crates: - ic-boundary parses its duration flags with jiff's friendly duration format and formats the timestamp of websocket log messages with jiff. - rate-limits-api and ic-nervous-system-humanize use a vendored copy of humantime 2.4.0's duration parser and formatter, so stored rule strings and NNS/SNS durations keep their exact semantics. - Golden tests, captured from humantime 2.4.0, pin the parsed and formatted values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- parse_duration rejects a duration with months or years with "months and years are not supported, use days or weeks", instead of jiff's error that names `jiff::SpanRelativeTo::days_are_24_hours()`. - Tests pin the inputs that the friendly format and humantime, which still parses the flags of ic-bn-lib, treat differently, and the largest value per unit that a jiff span accepts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
The zero special case is checked before trimming, incorrectly rejecting whitespace-padded zero values and contradicting the intended trimmed-input behavior.
1 open issue
What changed in this PR
Removes direct use of unmaintained humantime from IC-owned crates while preserving governance and rate-limit duration semantics. Transitive dependencies remain.
Changes:
- Uses jiff for
ic-boundaryduration flags and websocket timestamps. - Vendors duration parsing and formatting for governance and rate-limit APIs, including an overflow fix.
- Updates Cargo/Bazel dependencies and adds compatibility tests.
| File | Description |
|---|---|
| rs/nervous_system/humanize/src/tests.rs | Adds duration compatibility tests. |
| rs/nervous_system/humanize/src/lib.rs | Registers the vendored module. |
| rs/nervous_system/humanize/src/humantime.rs | Vendors duration parsing and formatting. |
| rs/nervous_system/humanize/Cargo.toml | Removes direct humantime dependency. |
| rs/nervous_system/humanize/BUILD.bazel | Removes humantime build dependencies. |
| rs/boundary_node/rate_limits/api/src/schema_versions/v1.rs | Uses vendored helpers and tests rule compatibility. |
| rs/boundary_node/rate_limits/api/src/lib.rs | Registers the vendored module. |
| rs/boundary_node/rate_limits/api/src/humantime/tests.rs | Tests duration compatibility and overflow handling. |
| rs/boundary_node/rate_limits/api/src/humantime.rs | Vendors duration parsing and formatting. |
| rs/boundary_node/rate_limits/api/Cargo.toml | Removes direct humantime dependency. |
| rs/boundary_node/rate_limits/api/BUILD.bazel | Removes humantime build dependencies. |
| rs/boundary_node/ic_boundary/src/metrics.rs | Uses jiff timestamps with formatting tests. |
| rs/boundary_node/ic_boundary/src/cli.rs | Adds jiff duration parsing and behavior tests. |
| rs/boundary_node/ic_boundary/Cargo.toml | Replaces humantime with jiff. |
| rs/boundary_node/ic_boundary/BUILD.bazel | Switches build targets to jiff. |
| Cargo.toml | Replaces the workspace dependency. |
| Cargo.lock | Updates affected crate dependencies. |
| Cargo.Bazel.toml.lock | Updates direct Bazel dependencies. |
| Cargo.Bazel.json.lock | Updates dependency metadata and checksum. |
| bazel/rust.MODULE.bazel | Replaces humantime’s specification with jiff’s. |
Review effort: Balanced
There was a problem hiding this comment.
🔵 Needs a closer look
Operator confirmation is needed because the boundary-node CLI rejects previously accepted duration syntax, and repository defaults and golden tests do not cover deployed CLI or environment values.
No open issues 🎉
1 resolved since last review
Review effort: Balanced
# Conflicts: # Cargo.Bazel.json.lock
The push of 141181f during GitHub's 2026-12-02 Actions incident started no workflow runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e parser ic-boundary's own 15 duration flags parsed jiff's "friendly" format, whose grammar differs from humantime's, so one command line accepted two grammars: the flags ic-boundary takes from ic-bn-lib still use humantime's. They now use the copy of humantime 2.4.0's parser that rate-limits-api already vendors, so every duration flag parses as before this PR, except that a value that overflows is an error instead of a panic. ic-bn-lib's own replacement, `ic_bn_lib::parse_duration` (dfinity/ic-bn-lib#164), ports the same parser. The timestamps of websocket log messages are formatted with `time`, as humantime's `format_rfc3339` formatted them, so no IC crate depends on jiff anymore. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…red crate rate-limits-api and ic-nervous-system-humanize each had a copy of humantime 2.4.0's duration parser and formatter, identical apart from where the tests live, and ic-boundary used rate-limits-api's through `pub mod humantime`. All three now depend on the new crate rs/utils/humantime-vendored, owned by the dfinity/node team, which holds that copy and its golden tests unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
This pull request changes code owned by the Governance team. Therefore, make sure that
you have considered the following (for Governance-owned code):
-
Update
unreleased_changelog.md(if there are behavior changes, even if they are
non-breaking). -
Are there BREAKING changes?
-
Is a data migration needed?
-
Security review?
How to Satisfy This Automatic Review
-
Go to the bottom of the pull request page.
-
Look for where it says this bot is requesting changes.
-
Click the three dots to the right.
-
Select "Dismiss review".
-
In the text entry box, respond to each of the numbered items in the previous
section, declare one of the following:
-
Done.
-
$REASON_WHY_NO_NEED. E.g. for
unreleased_changelog.md, "No
canister behavior changes.", or for item 2, "Existing APIs
behave as before.".
Brief Guide to "Externally Visible" Changes
"Externally visible behavior change" is very often due to some NEW canister API.
Changes to EXISTING APIs are more likely to be "breaking".
If these changes are breaking, make sure that clients know how to migrate, how to
maintain their continuity of operations.
If your changes are behind a feature flag, then, do NOT add entrie(s) to
unreleased_changelog.md in this PR! But rather, add entrie(s) later, in the PR
that enables these changes in production.
Reference(s)
For a more comprehensive checklist, see here.
GOVERNANCE_CHECKLIST_REMINDER_DEDUP
|
✅ No security or compliance issues detected. Reviewed 3 of 5 changed files (2 skipped) up to 7b13645. Security Overview
Detected Code Changes
|
|
✅ No security or compliance issues detected. Reviewed 3 of 4 changed files (1 skipped) up to 7b13645. Security Overview
Detected Code Changes
|
|
✅ No security or compliance issues detected. Reviewed 5 of 7 changed files (2 skipped) up to 7b13645. Security Overview
Detected Code Changes
|
There was a problem hiding this comment.
title suggestion: Use own copy of humantime library.
This answers "replace it WITH WHAT?". Then, the description should begin with something like
Because the original is no longer maintained (as of Oct 2026).
This quickly answers the next obvious question: WHY?
So, does this mean we are taking over the job of maintaining humantime? I mean, presumably not -> I'm not really sure what problem is solved by us copying their code into our repo. I guess if there is a bug, we can patch it quickly?
re the original title of this PR: not sure what you mean by "in the IC's own crates"? I mean, it is completely understood that the ic repo is the whole context here, since this PR is in the ic repo itself. Therefore, I'm not sure what (if anything) "in the IC's own crates" is supposed to add.
There was a problem hiding this comment.
I am certainly not against these new tests. Please, keep them.
but why are these suddenly being added? Did something special trigger this? I mean, if we literally just copied their code, there's "no chance" of changing the behavior, right? I guess this is just belt and suspenders?
| ("100wk", Ok(60_480_000)), | ||
| ("1month", Ok(2_630_016)), | ||
| ("3months", Ok(7_890_048)), | ||
| ("12M", Ok(31_560_192)), |
There was a problem hiding this comment.
In Governance, 1 month is exactly 1 / 12 of a year, and 1 year is defined as 365.25 days (precisely). (And 1 day is defined "normally".) These units are pretty cursed. I'm just the messenger.
So, 1 month = 2_629_800 s.
Therefore, I would leave these cases out too (similar to the subsecond cases).
| "unknown time unit \"mo\", supported units: ns, us/µs, ms, sec, min, hours, days, weeks, months, years (and few variations)", | ||
| ), | ||
| ), | ||
| ("1μs", Err("invalid character at 1")), |
There was a problem hiding this comment.
hmm. it is sad to me that this is not acceptable to humantime. I mean "μs" is completely standard. Oh well...
| ("1h30m", Ok(5400)), | ||
| (" 1h 30m ", Ok(5400)), | ||
| ("1\ts", Ok(1)), | ||
| ("1\ns", Ok(1)), |
There was a problem hiding this comment.
wow. unit being on another line should probably be considered not acceptable. OTOH, I guess it's not technically harmful?? Maybe, we can (again) simply not test this case?
| ("17nsec", Ok(0)), | ||
| ("17nanos", Ok(0)), | ||
| ("33ns", Ok(0)), | ||
| ("3usec", Ok(0)), | ||
| ("78us", Ok(0)), | ||
| ("163µs", Ok(0)), | ||
| ("31msec", Ok(0)), | ||
| ("31millis", Ok(0)), | ||
| ("6ms", Ok(0)), |
There was a problem hiding this comment.
We should maybe delete these cases, since we do not support subsecond resolution. I think we could add that later, but there is no plan to do that. Alternatively, these could be commented out.
| ("1m 1m", Ok(120)), | ||
| ("1h 1h", Ok(7200)), |
There was a problem hiding this comment.
Repetition is pretty confusing. I would suggest not testing these either.
(I mean, it's fine if the production code returns Ok, or whatever. My goal is just to avoid PROMISING anything in these cases. I would, for example, also be ok if these inputs caused Err to be returned.)
| (2_630_015, "30days 10h 33m 35s"), | ||
| (2_630_016, "1month"), | ||
| (5_260_032, "2months"), | ||
| (31_449_600, "11months 29days 3h 50m 24s"), | ||
| (31_557_599, "11months 30days 9h 50m 23s"), |
There was a problem hiding this comment.
Because of NNS's wacky definition of 1 month, I would get rid of these cases.
| (5_260_032, "2months"), | ||
| (31_449_600, "11months 29days 3h 50m 24s"), | ||
| (31_557_599, "11months 30days 9h 50m 23s"), | ||
| (31_557_600, "1year"), |
There was a problem hiding this comment.
This matches Governance's definition of "1 year".
| (126_230_400, "4years"), | ||
| (252_460_800, "8years"), | ||
| (378_691_200, "12years"), | ||
| (68_400_000, "2years 2months 6h 52m 48s"), |
There was a problem hiding this comment.
Ditto.
schneiderstefan
left a comment
There was a problem hiding this comment.
In this PR, the core protocol team was tagged for the utils files, even though the CODEOWNERS change clearly assigns them to the node team. I assume this is just a because the code owners change hasn't taken effect yet.
Approving so that we are not a blocker here, but I did not review the code that we not actually owning.

Removes humantime 2.4.0 from the IC's own crates. Stacked on #12381. It is unmaintained (RUSTSEC-2026-0542), and its repository was archived on 2026-10-07. The advisory stays in
Cargo.lockandCargo.Bazel.*.lockuntil ic-bn-lib (0.11.0), ic-gateway (v0.7.6) and tarpc (0.38.0) release versions without humantime.Changes
humantime-vendored(rs/utils/humantime-vendored, owned by@dfinity/node) is a vendored copy of humantime 2.4.0's duration parser and formatter, with humantime's copyright and MIT/Apache-2.0 notice.rate-limits-api(compiled into the rate-limit canister),ic-nervous-system-humanizeandic-boundaryuse it. So rule strings, NNS/SNS durations andic-boundary's own 15 duration flags keep humantime's grammar and semantics (month = 2,630,016 s, year = 31,557,600 s), like the flagsic-boundarytakes from ic-bn-lib. ic-bn-lib's own replacement,ic_bn_lib::parse_duration(Update all dependencies and Rust to 1.100.1 ic-bn-lib#164), ports the same parser.ic-boundaryformats thetimestampof websocket log messages withtime, the way humantime'sformat_rfc3339did.humantimeworkspace dependency andcrate.specare removed.ic-boundaryasks fortime'smacrosfeature, which thetimecrate.specgets too.ic-admintests) and edge cases, forhumantime-vendoredand for the wrappers inic-nervous-system-humanize.ic-boundary's tests check its 15 defaults and that its flags take humantime's grammar.Behaviour changes
u64::MAXseconds (e.g.18446744073709551615s 1000000000ns) now returns the overflow error instead of panicking. This applies toic-boundary's duration flags, rate-limit rules and NNS/SNS durations.🤖 Generated with Claude Code