Skip to content

godslayerakp/http: Add block to get response body as data:URL (#2426)#17

Merged
supervoidcoder merged 1 commit intoOmniBlocks:masterfrom
TurboWarp:master
Apr 5, 2026
Merged

godslayerakp/http: Add block to get response body as data:URL (#2426)#17
supervoidcoder merged 1 commit intoOmniBlocks:masterfrom
TurboWarp:master

Conversation

@supervoidcoder
Copy link
Copy Markdown
Member

implements TurboWarp#2364.


implements #2364.

---------

Co-authored-by: DangoCat[bot] <dangocat@users.noreply.github.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 5, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 087b1e55-0d09-4f38-95e2-a629cd24b20e

📥 Commits

Reviewing files that changed from the base of the PR and between 1a46b57 and 11936e4.

📒 Files selected for processing (1)
  • extensions/godslayerakp/http.js

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a new reporter block that exposes HTTP response data as Data URLs, enabling efficient conversion and handling of response content in various formats.

Walkthrough

Added a new reporter block resDataUrl to the HTTP request handler that exposes fetched response bodies as Data URLs. The implementation lazily creates and caches a Promise by converting the response blob via FileReader, while updating response parsing to store the blob first and derive text from it.

Changes

Cohort / File(s) Summary
HTTP Response Data URL Conversion
extensions/godslayerakp/http.js
Added resDataUrl() reporter block to lazily convert response blobs to Data URLs with caching. Updated sendRequest() response parsing to store blob first, then derive text from blob instead of directly calling res.text().

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 A blob hops down the data road,
Through FileReader's gleaming code,
To Data URL it transforms bright,
Once cached, forever in sight!
Response bodies dance in delight. 🌟

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@supervoidcoder supervoidcoder reopened this Apr 5, 2026
@supervoidcoder supervoidcoder merged commit e64acc6 into OmniBlocks:master Apr 5, 2026
6 of 11 checks passed
Copy link
Copy Markdown

@amazon-q-developer amazon-q-developer bot left a comment

Choose a reason for hiding this comment

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

This PR adds functionality to retrieve HTTP response bodies as data:URLs, but there are critical logic errors that will prevent the feature from working correctly:

Critical Issues:

  1. The blob property is never initialized in defaultResponse, causing undefined access
  2. The resDataUrl() method has Promise caching issues that will return stale data after new requests
  3. Race condition between clearAll() and blob assignment could cause empty data:URLs
  4. The Promise caching approach is incompatible with the clearAll() reset pattern

Required Changes:

  • Add blob: null to the defaultResponse object
  • Fix the Promise caching strategy to work correctly with the request/response lifecycle
  • Consider whether data:URL should be pre-computed during sendRequest() instead of lazy-loaded

Please address these blocking issues before merge.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

resDataUrl() {
if (!this.response.dataUrl) {
this.response.dataUrl = new Promise((resolve) => {
const blob = this.response.blob;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 Logic Error: Undefined property access. The blob property is never initialized in defaultResponse (line 216-226), causing this.response.blob to be undefined when accessed here. This will result in an empty being returned even when a valid response exists.

Add blob: null to the defaultResponse object in the static getter around line 222.

Comment on lines +574 to +589
resDataUrl() {
if (!this.response.dataUrl) {
this.response.dataUrl = new Promise((resolve) => {
const blob = this.response.blob;
if (blob) {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = () => resolve("");
reader.readAsDataURL(blob);
} else {
resolve("");
}
});
}
return this.response.dataUrl;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 Logic Error: The method creates and caches a Promise but lacks async declaration. Scratch reporters expect either synchronous values or promises from async methods. This implementation returns a Promise that resolves to a string, but the caching logic will cause subsequent calls to return the same Promise object even if clearAll() resets the response. This could lead to stale values being returned after new requests.

Comment on lines +717 to +718
this.response.blob = await res.blob();
const body = await this.response.blob.text();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛑 Logic Error: After clearAll() is called at line 670, this.response.blob will be reset but this.response.dataUrl (the cached Promise) won't exist in the new defaultResponse object. This means the Promise caching in resDataUrl() won't work correctly across multiple requests - the first call after a new request will recreate the Promise even though the blob might not be set yet. The blob is set later at line 717, creating a race condition where resDataUrl() might be called before the blob is available.

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