Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

media parameter is missing Error on Main Branch #1183

Closed
tcm390 opened this issue Dec 17, 2024 · 9 comments
Closed

media parameter is missing Error on Main Branch #1183

tcm390 opened this issue Dec 17, 2024 · 9 comments
Assignees
Labels

Comments

@tcm390
Copy link
Collaborator

tcm390 commented Dec 17, 2024

Description
When attempting to call the image-generation on Twitter, the following error occurs on the main branch:

Error: {"errors":[{"code":38,"message":"media parameter is missing."}]}
    at uploadMedia (node_modules/agent-twitter-client/dist/node/esm/index.mjs:2211:13)
    at async createCreateTweetRequest (node_modules/agent-twitter-client/dist/node/esm/index.mjs:1954:22)

However, it works as expected on the tcm-twitter-image branch.

@tcm390 tcm390 added the bug Something isn't working label Dec 17, 2024
@tcm390 tcm390 self-assigned this Dec 17, 2024
@tcm390
Copy link
Collaborator Author

tcm390 commented Dec 17, 2024

Just noticed it works only if disable Near plugin. I'm not sure why the ref-sdk in the Near plugin is causing an error with Twitter image posting—maybe there's a conflict. I think we should make the plugin configurable so people can choose which plugins they want to use. Right now, there are too many plugins, which also makes it really hard to debug.

@hroyo
Copy link

hroyo commented Dec 30, 2024

the same problem happens for action callbacks which use sendTweet as well.

@AIFlowML
Copy link
Collaborator

AIFlowML commented Jan 3, 2025

Hello here !
Can you test with ur latest version and report back ?
There was significant changes maybe is already resolved if not we will work on it.

Here some tips

TLDR (Executive Summary)

  • Issue Essence: Missing media parameter error in Twitter image-generation function.
  • Root Cause: Incorrect or missing filePath in content passed to uploadMedia function.
  • Solution Approach: Validate filePath, debug content generation, compare branches, enhance logging and error handling.
  • Impact Assessment: Affects media upload and tweet creation functionality, potentially impacting user experience.

Quick Resolution Path

  1. Immediate Steps:

    • Ensure filePath is correctly provided in the content passed to uploadMedia.
    • Add logging to capture the content being passed to uploadMedia.
    • Compare main and tcm-twitter-image branches for differences in media handling.
  2. Exact File Locations and Line Numbers:

    • packages/plugin-0g/src/actions/upload.ts (Line: Validation of filePath)
    • packages/client-twitter/src/post.ts (Line: createCreateTweetRequest function)
  3. Required Code Changes:

    • upload.ts:
      if (!filePath) {
          console.error("File path is required");
          throw new Error("File path is required"); // Add error handling
      }
    • post.ts:
      createTweetObject(tweetResult: any, client: any, twitterUsername: string): Tweet {
          return {
              id: tweetResult.rest_id,
              photos: [], // Ensure this is populated correctly
              ...
          } as Tweet;
      }
  4. Validation Commands:

    • Run unit tests for uploadMedia and createCreateTweetRequest.
    • Use logging to verify filePath is correctly passed.
  5. Rollback Procedures:

    • Revert to the tcm-twitter-image branch if issues persist.
    • Ensure backups of current code before making changes.

Comprehensive Solution

  1. Detailed Technical Analysis:

    • The uploadMedia function fails due to missing filePath, leading to an undefined media parameter.
    • The createCreateTweetRequest function relies on this media parameter, causing the error.
  2. Step-by-Step Implementation:

    • Step 1: Validate filePath in uploadMedia.
    • Step 2: Debug content generation to ensure filePath is included.
    • Step 3: Compare branches to identify discrepancies in media handling.
    • Step 4: Implement logging to capture content and parameters.
    • Step 5: Enhance error handling to manage missing media parameters.
  3. Dependencies and Side Effects:

    • Dependencies: Ensure all media handling functions are correctly integrated.
    • Side Effects: Potential impact on tweet creation if media handling changes.
  4. Configuration Changes:

    • Update configuration files to include detailed media handling instructions.
  5. Environment Requirements:

    • Ensure all environments have the necessary logging and error handling mechanisms.

@AIFlowML
Copy link
Collaborator

AIFlowML commented Jan 6, 2025

@tcm390 please let me know if this is solved or not and if there are conflictas please report them into a new more detailed issue so we can all together find a solution.

@tcm390
Copy link
Collaborator Author

tcm390 commented Jan 6, 2025

Just tested the latest develop branch, It hasn't been resolved

@hroyo
Copy link

hroyo commented Jan 6, 2025

It is easy to reproduce - try any image generation via Twitter with the Near plugin on.

@AIFlowML
Copy link
Collaborator

Not resolved seems

@rferrari
Copy link
Contributor

Nope, same issue here:
 ◎ LOGS
   Image generation successful, number of images:                                
   1 

 ◎ LOGS
   Processing image 1:                                                           
   generated_1737446084263_0 

 ◎ LOGS
   Generated caption for image 1:                                                
   ... 

/media/72FE6F8EFE6F4985/eliza-main/node_modules/@primuslabs/zktls-core-sdk/dist/algorithm/client_plugin.js:1
var Module=typeof Module!="undefined"?Module:{};var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=... (Goes on forever....)
then:
Error: {"errors":[{"code":38,"message":"media parameter is missing."}]}
    at uploadMedia (file:///media/72FE6F8EFE6F4985/eliza-main/node_modules/agent-twitter-client/dist/node/esm/index.mjs:2334:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)                                                                                
    at async Promise.all (index 0)
    at async createCreateTweetRequest (file:///media/72FE6F8EFE6F4985/eliza-main/node_modules/agent-twitter-client/dist/node/esm/index.mjs:1975:22)
    at async Scraper.sendTweet (file:///media/72FE6F8EFE6F4985/eliza-main/node_modules/agent-twitter-client/dist/node/esm/index.mjs:3503:12)
    at async file:///media/72FE6F8EFE6F4985/eliza-main/packages/client-twitter/dist/index.js:14:36
    at async RequestQueue.processQueue (file:///media/72FE6F8EFE6F4985/eliza-main/packages/client-twitter/dist/index.js:32:17)

Node.js v23.3.0
/media/72FE6F8EFE6F4985/eliza-main/agent:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @elizaos/[email protected]+build.1 start: `node --loader ts-node/esm src/index.ts "--isRoot" "--characters=./characters/character.json"`                                                                         
Exit status 7
 ELIFECYCLE  Command failed with exit code 7.

@aminlatifi
Copy link

@AIFlowML @rferrari I solved it. Explained the root cause here
#3154 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants