Skip to content

🐛 fix panic in ArrayLike resources#6272

Merged
slntopp merged 3 commits intomainfrom
mik/fix-panic-in-arraylike-resources
Dec 8, 2025
Merged

🐛 fix panic in ArrayLike resources#6272
slntopp merged 3 commits intomainfrom
mik/fix-panic-in-arraylike-resources

Conversation

@slntopp
Copy link
Copy Markdown
Member

@slntopp slntopp commented Dec 5, 2025

Fixes:

  1. compile-time panic when .sample is called on a array-like resource (e.g. users)
    Example: users.where(false).sample()
  2. mqlc panic in query #6196
    map is expected to always return an explicit ArrayLike type, which isn't happening in the runtime if list value is empty
  3. Adds guardrails to prevent similar panics in the future with the other ArrayLike operations on resources

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Dec 5, 2025

Test Results

4 677 tests  +3   4 673 ✅ +3   2m 17s ⏱️ -1s
  415 suites ±0       4 💤 ±0 
   31 files   ±0       0 ❌ ±0 

Results for commit 7bfb157. ± Comparison against base commit 275e87d.

♻️ This comment has been updated with latest results.

@slntopp slntopp marked this pull request as ready for review December 5, 2025 16:37
list := items.Value.([]any)
if len(list) == 0 {
return bind, 0, nil
list, ok := items.Value.([]any)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we add a test to ensure we do not accidentally get a regression?

@slntopp slntopp force-pushed the mik/fix-panic-in-arraylike-resources branch from cfe5826 to cfec048 Compare December 8, 2025 17:56
…urce (e.g. `users`)

Example: `users.where(false).sample()`
Fixes #6196

map is expected to always return an explicit ArrayLike type, which isn't happening in the runtime if list value is empty
@slntopp slntopp force-pushed the mik/fix-panic-in-arraylike-resources branch from cfec048 to 7bfb157 Compare December 8, 2025 18:05
@slntopp slntopp merged commit 088918d into main Dec 8, 2025
17 checks passed
@slntopp slntopp deleted the mik/fix-panic-in-arraylike-resources branch December 8, 2025 18:16
@github-actions github-actions bot locked and limited conversation to collaborators Dec 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants