Skip to content

Conversation

@andreaanez
Copy link
Contributor

@andreaanez andreaanez commented Oct 22, 2025

We are running into a race condition where confirmation steps lead to time now being past 1 min

@semanticdiff-com
Copy link

semanticdiff-com bot commented Oct 22, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  src/schema.ts  9% smaller
  src/lib/nodes/create.ts  0% smaller

@andreaanez andreaanez changed the title now is translated to None value as time for reserved nodes in Nodes API "Now" is translated to None value as time for reserved nodes in Nodes API Oct 22, 2025
Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@andreaanez andreaanez changed the title "Now" is translated to None value as time for reserved nodes in Nodes API [ENG-2326] "Now" is translated to None value as time for reserved nodes in Nodes API Oct 22, 2025
@andreaanez andreaanez marked this pull request as ready for review October 22, 2025 17:57
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Overview

Summary

Fixed redundant code in reserved node creation logic that was incorrectly setting start_at when user provided "NOW" as start time, and updated TypeScript schema to properly reflect that start_at can be number | null.

Key changes:

  • Removed lines 259-260 in create.ts that set start_at in the else clause, since line 279-284 unconditionally override this value anyway
  • Updated schema type for start_at from number to number | null to align with API requirements
  • The logic now correctly handles "NOW" start times: validation passes at line 261, and final timestamp is set at lines 279-284

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The changes remove redundant code that was being overridden anyway, and update the schema to match API requirements. The logic flow remains correct: when start === "NOW", the validation passes and the final timestamp is properly set at lines 279-284. No behavioral changes, just cleanup.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
src/lib/nodes/create.ts 5/5 Removed redundant code that was setting start_at for "NOW" case since it was being overridden by lines 279-284 anyway
src/schema.ts 5/5 Updated TypeScript schema to allow start_at to be `number

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI
    participant Parser as parseStartDateOrNow
    participant Validation
    participant API as Nodes API

    User->>CLI: sf nodes create --start NOW --duration 1h
    CLI->>Parser: parseStartDateOrNow("NOW")
    Parser-->>CLI: "NOW" (string)
    
    Note over CLI: createParams.start_at not set<br/>(lines 256-258 skipped)
    
    CLI->>Validation: Check if "NOW" is valid
    Validation-->>CLI: Valid (startDate === "NOW")
    
    Note over CLI: Lines 279-284: Set final start_at
    CLI->>CLI: start_at = Math.floor(new Date().getTime() / 1000)
    
    CLI->>API: POST /nodes/create {start_at: <timestamp>, ...}
    API-->>CLI: Node created
    CLI-->>User: Success
Loading

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@0xJepsen 0xJepsen left a comment

Choose a reason for hiding this comment

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

I am not a code owner here but these changes look fairly constrained and correct to me

@andreaanez andreaanez merged commit 7c89893 into main Oct 22, 2025
2 checks passed
Copy link
Member

@sigmachirality sigmachirality left a comment

Choose a reason for hiding this comment

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

small issues

  • you did not regenerate the Stainless SDK.
  • you directly edited the schema.ts instead of running deno task schema
    • the schema.ts does not affect the Stainless SDK.

big issues:

  • due to how the logic interacts with existing date hour rounding logic, this 1 line change doesn’t actually work.

Copy link
Contributor Author

Yikes ok.

Copy link
Contributor Author

If i revert this PR can I bribe you into doing it for me? Either that or I need an education here - will be stopping by desk to ask as well

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.

4 participants