Problem with reading properties in the code node

Describe the problem/error/question

I have a code node, which formats written article in the right way. The problem is that the image’s url and alt text is given to the node and it is there, the variable is not empty, but code still sees the json field as undefined.

What is the error message (if any)?

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

  • n8n version: 1.77.3 (Self Hosted)
  • Database (default: SQLite): Don’t know
  • n8n EXECUTIONS_PROCESS setting (default: own, main): main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
  • Operating system: Windows

When you merge two branches into the same node, the node will execute first for the upper branch and again for the lower branch.

So you might be having problems with the type of data that is coming in.

Your options are:

  • Using a Merge node to turn those 2 branches into only 1
  • Changing your logic to require only one branch

If my reply answers your question, please remember to mark it as a solution.

@solomon,


The upper branch works if there are no images.

As you can see the cycle has worked out good and output the url and alt text, which is later is marked as undefined and the problem stays.

One more point to think about is that the node works good when there is only one image in the cycle.

Oh, I see. So only one branch will run anyways. Good.

Since you said it works when there’s only one image, try changing the Code node to “Run Once For Each Item”.

That way you will restrict the functionality to one item and it may fix your issue.

Small changes to the JavaScript code might be necessary.
But ChatGPT can do that for you, if you explain the context.

If you want me to debug it for you, please provide the output from the Merge node.

I can copy it and run only the 2 nodes at the end.

  • Here is the whole scheme.

Here is the part after Merge

Here is the example of the output of the Merge:
[
{
“images”: [
{
“url”: “https://172.31.15.81/wp-content/uploads/2025/02/pexels-photo-6864668-1.jpeg-1.jpeg”,
“alt”: “Image illustrates Rug pull scenario infographic”
}
]
},
{
“content”: [
“H2: What is a Crypto Rug Pull?\nA rug pull in cryptocurrency is a scenario where the project’s creators abruptly withdraw funds from the liquidity pool and disappear, leaving investors high and dry. This leads to serious financial losses as the price of the tokens plummets. Rug pulls are increasingly prevalent in the decentralized finance (DeFi) space, where investor protection mechanisms may be limited.\n\nRug pulls can be categorized distinctly from other forms of cryptocurrency scams because they often involve the sudden removal of liquidity by developers. Unlike phishing scams or Ponzi schemes, which rely on continuous engagement with the victims, a rug pull is executed swiftly once substantial investment is secured, leaving no recourse for the investors.\n\nThese scams are particularly prevalent in DeFi markets due to the relatively unregulated and anonymous nature of transactions. Developers may create new tokens and hype them up through various means, including social media or influencer promotions, drawing in unsuspecting investors. Once the project gains momentum and achieves enough liquidity, the creators perform the rug pull, crashing the token’s value.\n\nUnderstanding the rug pull crypto meaning is critical for prospective investors in digital assets. Common indicators of such scams include anonymous developer teams, unnaturally high yields, and unaudited contracts. Awareness of these signs can help protect investments and minimize the risks associated with the ever-expanding decentralized financial ecosystem.\n\n”,
“\nImage: Rug pull scenario infographic\nH2: How Rug Pulls Work\n\nUnderstanding the mechanics behind a rug pull in crypto is crucial for investors. Typically, developers orchestrate a rug pull by launching a project with the intent of running away with investor funds. Here’s a breakdown of how these scams function:\n\nFirst, developers create a new cryptocurrency token and attract attention through aggressive marketing campaigns. They often make unrealistic promises of high returns. This hype brings in investors fearing to miss out on potential profits. As capital amasses in the liquidity pools, these developers execute their exit strategy.\n\nIn the infamous act known as "pulling the rug," the scam initiators withdraw funds and abandon the project. This act of investor abandonment causes the token’s value to plummet, leaving only worthless assets for token holders. The motivations behind these crypto developer scams are purely driven by greed and a current lack of regulation in the crypto space, which lets such schemes flourish.\n\nTo prevent becoming a victim of rug pulls in crypto, it’s essential to understand how rug pulls function critically. Investors should also thoroughly assess the credibility of developers and their projects. Checking for locked liquidity and identifying developers can act as precautionary measures.\n\nBy fully appreciating the mechanics of these crypto developer scams and being aware of common exit strategies, investors can better protect themselves against this prevalent threat in the decentralized finance (DeFi) ecosystem.\n\n”,
“H2: Notable Examples of Rug Pulls\nThe realm of cryptocurrency has been plagued by numerous rug pulls, leaving investors counting their losses. One significant rug pull that stands out in the crypto sphere is Bitconnect. It was a cryptocurrency platform that promised high and seemingly guaranteed returns, drawing in an enormous amount of investor interest and funds. Initially, Bitconnect gained massive traction by offering participants up to 1% daily returns through a seemingly legitimate lending platform. However, in 2018, the scheme unraveled, leading to its sudden collapse, leaving investors with nothing and millions of dollars vanished overnight.\n\nAnother prime example in the crypto world was a decentralized finance (DeFi) project that surfaced promising innovative financial services. Despite initial investor confidence, the developers of this project swiftly executed an exit strategy, siphoning off with the funds. This rug pull highlighted the vulnerabilities within the DeFi space and underscored the risks associated with investing in unproven crypto projects. Such crypto rug pull cases emphasize the unpredictability and scam prevalence in the crypto market.\n\nThe Squid Game token’s collapse serves as yet another cautionary tale. Riding on the viral popularity of the Netflix series, this token managed to solicit sizable investments due to its enticing narrative. However, it was nothing more than a facade put up by anonymous developers who, after raking in millions, executed their exit strategy. This collapse drained investment portfolios and fueled skepticism around emerging tokens and their legitimacy.\n\nThrough these examples, common threads remain: lucrative promises, anonymous developers, and a lack of verifiable credibility. These characteristics should serve as warning signs for investors, encouraging due diligence and cautious investment strategies in the volatile crypto market. The existence of these scams continues to affect investor confidence and market stability.\n\n”,
“H2: Warning Signs to Detect a Rug Pull\nIn the crypto world, being able to detect a rug pull can safeguard your investments and prevent substantial losses. Recognizing a rug pull involves keen attention to warning signs like excessive promises and lack of transparency. Here are crucial indicators of potential rug pulls:\n\n- Unrealistic Promises: Projects that offer guaranteed high returns are major red flags. Legitimate investments emphasize risk along with rewards, and no legitimate project can assure high returns without risk.\n\n- Lack of Documentation: Missing or poorly written whitepapers indicate potential transparency issues, pointing towards a possible rug pull. Always assess the quality and availability of crucial documents like whitepapers and technical audits.\n\n- Anonymity of Team: Projects with developers who hide their identities can be concerning. Credible teams are typically transparent about experience and backgrounds, fostering trust and accountability.\n\n- Limited Community Engagement: Sparse community interaction might signal a reluctance to engage with investors who could question the project’s legitimacy. Active and vibrant communities typically indicate a project’s authenticity.\n\n- Project Transparency: Absence of a clear roadmap or frequent updates could signify directionless projects, while credible projects keep investors informed with continuous updates.\n\n- Developer Credibility: Researching developer backgrounds is vital. A background with accomplished ventures provides confidence, whereas questionable pasts are concerning.\n\n- Community Engagement: Thriving communities that allow open discussions reflect transparency. Look for projects where community members can freely ask questions and engage.\n\nBeing vigilant about these warning signs helps in assessing project legitimacy and can mitigate risks related to potential rug pulls.\n\n”,
“H2: How to Safeguard Against Rug Pulls\n\nPreventing rug pulls in the crypto space requires strategic approaches that enhance investment safety and secure investment strategies. To mitigate the risk of fraudulent schemes, consider the following practical steps:\n\n- Conduct Thorough Research: Before investing, delve into the background of a project. Understand the team’s history, check for transparent communication, and verify the project’s legitimacy through reliable sources.\n- Diversify Investments: By spreading your investments across various projects, you minimize the risk. This strategy ensures that even if one project fails, your entire portfolio is not compromised.\n- Use Technology: Leverage tools and software that monitor token movements and alert you to suspicious activity. These resources can provide real-time insights into potential threats.\n- Follow Community Feedback: Join forums and discussion groups where investors share their experiences and insights. Engaged communities offer valuable perspectives and may highlight concerns you’ve overlooked.\n- Revisit Strategies Regularly: Crypto markets evolve rapidly. Regularly review your strategies and adapt as necessary. Stay informed about market trends and be ready to adjust your approach in response to new information.\n\nIncorporating these strategies into your investment process can significantly reduce the likelihood of falling victim to rug pulls. Due diligence, ongoing research, and proactive safety measures are key to safeguarding your investments. Stay vigilant and prioritize transparency to maintain a secure investment environment.\n\n”,
“H2: Fiscal Impact of Rug Pulls on the Crypto Market\nThe occurrence of rug pulls significantly alters the economic landscape of the cryptocurrency market. These damaging activities not only strip investors of their funds but also contribute to widespread financial instability. The economic effects of rug pulls are profound, leading to sharp declines in investor confidence, which is already a fragile commodity in the volatile world of cryptocurrencies.\n\nMarket trust issues permeate every investment decision following a rug pull. As investors grapple with the aftermath, the repercussions spread throughout the market ecosystem. This results in hesitancy towards new and upcoming projects, which are often seen as potentially high-risk due to the prevalence of scams that mimic legitimate schemes. Consequently, the economic repercussions extend beyond immediate financial losses; they weaken the foundation upon which market growth relies.\n\nHistorical trends reveal that major rug pulls often lead to temporary but significant declines in overall cryptocurrency market capitalization. For instance, when a prominent project faces sudden collapse due to fraudulent activities, the market reacts sharply. This creates a domino effect, where investor sell-offs lead to plummeting prices, affecting not just the involved currencies but also permeating across the sector. Such market downturns underscore the need for sustained vigilance and enhanced security measures.\n\nMoreover, rug pulls contribute to a long-lasting environment of skepticism. When investors witness peers falling prey to scams, they become increasingly vigilant, often to the point of avoiding new projects altogether. This mentality hinders the ability of legitimate innovators to gain traction, as potential backers may choose to sit on the sidelines rather than risk financial loss. Consequently, the ecosystem suffers from reduced capital inflow, stifling the growth of innovative technologies that require financial support to thrive.\n\nTo restore market confidence and deter fraudulent activities, consistent regulatory measures are critical. These measures should aim to increase transparency and accountability across platforms. By fostering an environment of trust and integrity, the crypto market can not only mitigate immediate economic repercussions but also build a more resilient foundation for future growth.\n\n”,
“H2: Community Measures to Prevent Rug Pulls\n\nCommunity initiatives that foster education and transparency are key factors in reducing rug pull incidents. By using platforms for shared knowledge, investors stay informed about potential threats and best practices. Active communities often share insights and alerts, enhancing investor safety.\n\nEducating Investors\n- Forums and webinars help in spreading information about preventing rug pulls.\n- Online courses empower investors with tools for thorough research.\n\nInvestor education also extends to promoting social responsibility within the crypto community. Encouraging discussions on ethics and accountability helps nurture a more trustworthy environment, supporting community growth. Engaged communities are better equipped to identify red flags, ensuring transparency and ethical standards.\n\nCommunity Resources\n- Development of tools to detect rug pulls early.\n- Creation of databases to spot patterns and alert others.\n\nOverall, these community-driven initiatives foster a culture of transparency and education, crucial for safeguarding investments and promoting a healthy crypto ecosystem.\n\n”,
“H2: The Role of Regulations in Mitigating Rug Pull Risks\n\nRegulatory bodies worldwide are increasingly stepping up their efforts to address the prevalence of scams in the cryptocurrency sector, particularly those related to rug pulls. Implementing comprehensive regulations for crypto projects is crucial in creating a safer investment environment. These regulations serve to deter fraudulent actors and provide greater legal protections for investors. However, striking the right balance between regulation and innovation remains a challenge.\n\nWhen regulatory frameworks are robust and well-defined, they contribute significantly to combatting scams in crypto. Some common regulatory measures include:\n- Mandatory disclosures\n- Periodic audits\n- Requirements for project teams to hold identifiable accountability\n\nSuch measures reduce anonymity—a commonly exploited factor in scam-related rug pulls. Effective policy development ensures that crypto projects operate with transparency and integrity, fostering trust within the community.\n\nDespite these advances, some critics argue that excessive regulation might stifle innovation within the crypto space, potentially slowing down growth and development. It remains essential for regulators to engage with industry stakeholders to craft policies that both protect investor interests and allow for technological advancements to flourish.\n\nThe legal landscape is evolving rapidly, with some regions leading in terms of comprehensive regulations, while others lag behind. Therefore, international collaboration and knowledge sharing can enhance regulatory effectiveness across borders, making the global crypto market a safer place for investors.\n\n”,
“H2: Conclusion\n\nInvesting securely in crypto is an intricate balance of careful awareness and vigilant risk management. While the allure of high returns is strong, the threat of rug pulls remains a substantial risk. Investors must gather information continuously, scrutinizing crypto ventures meticulously before diving in. Identifying signs of instability or potential deception can guide effective decision-making. By staying informed and cautious, investors can employ strategies that guard against fraud. Remaining vigilant in this dynamic market is crucial. The conclusion on rug pulls highlights that comprehensive research and informed choices are key. This approach not only shields investments but also builds confidence in navigating the complex crypto terrain. Thus, adopting a security-conscious and diligent mindset is indispensable for anyone engaging in cryptocurrency investments. Emphasizing proactive investing and ongoing knowledge acquisition will enhance investor security and market participation confidence.\n\n”,
“H2: FAQ\n\nQ1: What are the main characteristics of a rug pull?\nA rug pull in the crypto space involves developers abandoning a project abruptly, taking investors’ funds with them. Key characteristics include sudden withdrawal of liquidity, lack of transparent communication from the developers, and promises of unrealistic returns.\n\nQ2: How can I identify a rug pull in a new crypto project?\nTo address these concerns, identifying potential rug pulls involves being cautious about projects with anonymous developers, lack of a clear roadmap, or a visible presence online. Look out for excessive promises, such as guaranteed returns and extremely high yields. Additionally, engage with community discussions to gather more insights.\n\nQ3: What can investors do if they fall victim to a rug pull?\nIf investors suspect they are part of a rug pull, it’s crucial to report the incident to the relevant authorities or online forums to warn others. Consider attending community discussions and being active in forums to spread awareness. While recovery of funds might be difficult, increasing community awareness helps prevent further exploitation. It’s a reminder to only invest in projects with proven track records.\n\n”
]
}
]

Hey @ivankry,

I wasn’t able to fully debug the issue because your Code node gets data from nodes way back.

But here is some food for thought:

The error indicates that the object returned by the call $('Передаем ссылки на изображения').first().json does not have the images property defined, or that the imageIndex does not exist in the images array.

This could be happening because:

  • The selector $('Передаем ссылки на изображения') is not returning the expected object, or the JSON is not loaded correctly.
  • The images array does not exist or is empty.
  • The value of imageIndex is greater than the number of elements available in the images array.

My recommendation is to verify that the JSON is being passed correctly and that the images array contains the expected content.

What I like to do is to configure some extra nodes to aggregate ALL the data that is coming to the Code node.

That way you would be able to see every piece of data before trying to run code over it.

:point_right: If my reply answers your question, please remember to mark it as a solution.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.