Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 10, 2026

Adding a newly created contract as an inject to scenarios or atomic tests threw TypeError: inject_content[$.key].replaceAll is not a function. The code called .replaceAll() on field values that could be null, undefined, arrays, or numbers—not just strings.

Changes

Added typeof guards before all .replaceAll() calls on inject content fields:

  • InjectForm.tsx (line 152): Guard initialValues.inject_content[field.key]
  • InjectContentForm.tsx (line 177): Guard defaultValue when resetting fields
  • QuickInject.js (lines 399, 775, 787, 887): Guard field values across 4 code paths
// Before
if (field.type === 'textarea' && field.richText && defaultValue && defaultValue.length > 0) {
  defaultValue = defaultValue.replaceAll(...);
}

// After
if (field.type === 'textarea' && field.richText && typeof defaultValue === 'string' && defaultValue.length > 0) {
  defaultValue = defaultValue.replaceAll(...);
}

This handles contracts with uninitialized fields or multi-cardinality fields (arrays) that were triggering the error.

Original prompt

This section details on the original issue you should resolve

<issue_title>Error Occurs When create + adding a Contract as an Inject to a Scenario or Atomic Test</issue_title>
<issue_description>When adding a Contract as an Inject to a Scenario or an Atomic Test, an error is consistently reproduced

Environment
Pre-release / Testing

Tested on multiple scenarios and atomic tests

Issue occurs with different contract types

Reproducible Steps

Steps to create the smallest reproducible scenario:

  1. Open OpenAEV and CREATE A NEW CONTRACT (e.g. OCTI)
  2. navigate to Scenarios or Atomic Tests
  3. Create a new scenario or open an existing one
  4. Add the new contract created

Expected Output
The contract should be successfully added as an inject, allowing the scenario or atomic test to be saved and executed without errors

Actual Output

An error is triggered when adding the contract as an inject.
+
Sometimes the inject is not correctly created

Image

Image</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix error when adding contract as inject to scenario Fix TypeError when adding newly created contracts to injects Jan 10, 2026
Copilot AI requested a review from SamuelHassine January 10, 2026 10:41
@codecov
Copy link

codecov bot commented Jan 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 50.57%. Comparing base (b8c0b6a) to head (7a86c06).

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #4711   +/-   ##
=========================================
  Coverage     50.57%   50.57%           
  Complexity     3708     3708           
=========================================
  Files           903      903           
  Lines         26819    26819           
  Branches       2012     2012           
=========================================
  Hits          13563    13563           
  Misses        12437    12437           
  Partials        819      819           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Error Occurs When create + adding a Contract as an Inject to a Scenario or Atomic Test

2 participants