Skip to content

fix: compound ttl durations silently parsing as tiny values#390

Open
wadetregaskis wants to merge 1 commit into
shell-pool:masterfrom
wadetregaskis:3
Open

fix: compound ttl durations silently parsing as tiny values#390
wadetregaskis wants to merge 1 commit into
shell-pool:masterfrom
wadetregaskis:3

Conversation

@wadetregaskis

Copy link
Copy Markdown
Contributor

AI Policy Ack

AI Policy

Found by Claude Fable 5.

This PR was:

✅ completely vibe coded

Description

The suffix duration parser took the leading digit run as the value and the last character as the unit, ignoring everything in between, so a natural compound spec like 'shpool attach --ttl 1h30m' parsed as one MINUTE: the reaper killed the session 60 seconds in and the user lost their work. '2d12h' similarly meant 2 hours, '12.5h' meant 12 hours.

Require the unit character to directly follow the digits and end the string, so unsupported compound formats are rejected with an error instead of silently misinterpreted.

Note: this doesn't currently allow for whitespace between the digits and the unit, e.g. "1 h". I could make it tolerate that, if you prefer.

It also will fail for e.g. "1.0h" even though right now it happens to interpret that correctly (by accident).

The better fix might be to support [some] compound durations and floating-point values, like "1.5h" and "1h30m", but that's clearly under "nice to have feature" territory, so I didn't want to just jump to that without knowing if that would actually be desired.

The suffix duration parser took the leading digit run as the value and
the last character as the unit, ignoring everything in between, so a
natural compound spec like 'shpool attach --ttl 1h30m' parsed as one
MINUTE: the reaper killed the session 60 seconds in and the user lost
their work. '2d12h' similarly meant 2 hours, '12.5h' meant 12 hours.

Require the unit character to directly follow the digits and end the
string, so unsupported compound formats are rejected with an error
instead of silently misinterpreted.

@ethanpailes ethanpailes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compound durations should be expressed with colons. We should fix the parser to only accept a single unit

@ethanpailes

Copy link
Copy Markdown
Contributor

I'm happy to see you contributing, but please start with issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants