Skip to content

Conversation

@jakubno
Copy link
Member

@jakubno jakubno commented Jan 10, 2026

There's no ttl, so redis returns an error if you try to keep it. You have to explicitly set 0 (disabled)


Note

Fixes Redis update behavior to avoid TTL-related errors.

  • In packages/api/internal/sandbox/storage/redis/operations.go, change Set(..., redis.KeepTTL) to Set(..., 0) in Update so updates succeed when the key has no TTL, aligning with Add's behavior.

Written by Cursor Bugbot for commit 0f6a85f. This will update automatically on new commits. Configure here.

…s keys with no expiration (TTL = 0), but the Update method was trying to use redis.KeepTTL, which fails because there's no TTL to preserve.

// Execute transaction
err = s.redisClient.Set(ctx, key, newData, redis.KeepTTL).Err()
err = s.redisClient.Set(ctx, key, newData, 0).Err()
Copy link

Choose a reason for hiding this comment

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

Setting TTL to 0 means no expiration. Both Add() (line 29) and now Update() store keys without expiration, but the comment on line 28 says "with max expiration little bit longer than max instance length to prevent leaking". This means sandbox data will persist indefinitely in Redis unless explicitly removed via Remove(). If the cleanup logic fails, this could cause memory leaks. Consider either: (1) setting an actual TTL value (e.g., based on max instance lifetime), or (2) updating the comment to reflect that Redis is not being used as a TTL-based cache for sandboxes.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0f6a85f0bf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".


// Execute transaction
err = s.redisClient.Set(ctx, key, newData, redis.KeepTTL).Err()
err = s.redisClient.Set(ctx, key, newData, 0).Err()

Choose a reason for hiding this comment

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

P2 Badge Preserve TTL when updating sandbox entry

Using Set(..., 0) explicitly removes any existing TTL on the key. If sandbox entries ever have expirations set (e.g., via EXPIRE elsewhere or from prior versions), this update makes them persistent after any write, so they will never expire and can leak. The previous redis.KeepTTL preserved those expirations. Consider keeping TTLs (or reapplying the current TTL) when updating so updates don’t disable expiry for keys that have one.

Useful? React with 👍 / 👎.

@jakubno jakubno marked this pull request as draft January 12, 2026 13:50
@jakubno
Copy link
Member Author

jakubno commented Jan 12, 2026

Double checked and it's just intermittent, so this isn't probably the case. Will check it more later

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.

3 participants