Skip to content

RI-8222: Add array append endpoint#6128

Open
pawelangelow wants to merge 1 commit into
mainfrom
be/RI-8222/add-array-append-endpoint
Open

RI-8222: Add array append endpoint#6128
pawelangelow wants to merge 1 commit into
mainfrom
be/RI-8222/add-array-append-endpoint

Conversation

@pawelangelow

@pawelangelow pawelangelow commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

What

Adds POST /databases/:id/array/append for the array Modify vertical: appends a
value to the end of an array. The end index is computed server-side (current
ARLEN) — the client sends only keyName + value — and the written index is
returned. The key must already exist (404 otherwise); WRONGTYPE → 400, ACL
denial → 403.

Design notes

  • Read-then-set, not a Lua script. Append = ARLEN then ARSET key <len> value.
    An EVAL approach was rejected: Lua numbers are doubles, so it rounds the index
    inside the script above 2⁵³ and corrupts the write — a loss the upcoming
    ioredis fix could never repair.
  • Big-int index contract. The index is a decimal string end-to-end and is
    passed to ARSET as a string, so the write stays precise. Above 2⁵³ the only
    imprecision is ioredis parsing the ARLEN reply as a JS number — the transport
    limitation tracked by RI-8296 (stringNumbers). The integration test for
    that case is skipped and will flip green once ioredis is fixed, with no code
    change.
  • Not transactional. The client has no MULTI/WATCH yet (sendMulti is a
    TODO), so two concurrent appends can race on the same length. Acceptable for
    the desktop GUI, and still fresher than a UI-cached length.
  • ARINSERT is intentionally not used (its cursor starts at 0 on ARSET/ARMSET-built
    arrays, so it overwrites from the front; cursor positioning needs ARSEEK, v2).

Testing

  • Service unit tests: append returns the index, ARLENARSET call shape,
    404 / 400 / 403 paths.
  • Integration suite vs redis:8.8 (320 passing, 1 pending): append at end,
    consecutive appends, encoding=buffer, non-array → 400, missing key/instance →
    404, ACL authorised + -arset → 403, and the skipped >2⁵³ precision case.
  • Bruno request added under Array/Append Element.

Note

Medium Risk
New write path to live Redis data with a non-transactional ARLEN→ARSET sequence (concurrent appends can race); otherwise mirrors existing array modify patterns and error handling.

Overview
Adds POST /databases/:id/array/append so clients can append to an existing Redis array with only keyName and value. The server reads ARLEN, writes at that index via ARSET, and returns { keyName, index } (index as a decimal string).

Behavior and errors: Missing key → 404; wrong type → 400; ACL → 403. When length is 2^64-1 (no valid append index), the API returns 400 with ARRAY_IS_FULL instead of hitting Redis with an invalid index.

Tests & docs: Service unit tests, Redis 8.8 integration tests (including buffer encoding, full-array guard, ACL on arset), a test factory, and a Bruno request under Array/Append Element.

Reviewed by Cursor Bugbot for commit 05cd432. Bugbot is set up for automated code reviews on this repo. Configure here.

@pawelangelow pawelangelow self-assigned this Jun 29, 2026
@pawelangelow pawelangelow requested a review from a team as a code owner June 29, 2026 13:46
@jit-ci

jit-ci Bot commented Jun 29, 2026

Copy link
Copy Markdown

🛡️ Jit Security Scan Results

CRITICAL HIGH MEDIUM

✅ No security findings were detected in this PR


Security scan by Jit

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

Copy link
Copy Markdown

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: b644fec4c2

ℹ️ 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".

Comment thread redisinsight/api/src/modules/browser/array/array.service.ts
@github-actions

github-actions Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Code Coverage - Integration Tests

Status Category Percentage Covered / Total
🟡 Statements 79.11% 18044/22808
🟡 Branches 61.91% 8398/13563
🟡 Functions 66.9% 2450/3662
🟡 Lines 78.72% 16981/21571

@pawelangelow pawelangelow force-pushed the be/RI-8222/add-array-append-endpoint branch from b644fec to a347afe Compare June 29, 2026 13:55

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

Copy link
Copy Markdown

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: a347afe336

ℹ️ 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".

Comment thread redisinsight/api/src/modules/browser/array/array.service.ts
Add POST /array/append: appends a value to the end of an array by reading the
current length (ARLEN) and ARSETting at that index. Returns the written index.
The key must already exist (404 otherwise); WrongType maps to 400 and an ACL
denial to 403 via the standard catchAclError.

The index is carried as a decimal string end-to-end, matching the unsigned
64-bit index contract, and is passed to ARSET as a string so the write stays
precise. Above 2^53 the only imprecision is ioredis parsing the ARLEN reply as
a JS number (the transport limitation tracked by RI-8296); the integration
test for that case is skipped until ioredis returns 64-bit integers losslessly,
at which point it flips green with no code change.

Not wrapped in a transaction: the client has no MULTI/WATCH yet (sendMulti is a
TODO), so two concurrent appends can race on the same length. Acceptable for
the desktop GUI, and still fresher than a UI-cached length. An EVAL/Lua script
was rejected because Lua numbers are doubles, which would round the index
inside the script and corrupt the write above 2^53 — a loss the ioredis fix
could not repair.

ARINSERT is intentionally not used: its cursor starts at 0 on arrays built via
ARSET/ARMSET or loaded fresh, so it would overwrite from the front rather than
append to the end (the cursor needs ARSEEK, deferred to v2).

Covered by service unit tests, Bruno, and an integration suite (append at end,
consecutive appends, encoding=buffer, 404/400/403, plus a skipped >2^53 case).
Verified against redis:8.8 (320 passing, 1 pending).

References: #RI-8222

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pawelangelow pawelangelow force-pushed the be/RI-8222/add-array-append-endpoint branch from a347afe to 05cd432 Compare June 29, 2026 14:09
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.

1 participant