Developer forum

Forum » Dynamicweb 10 » Bulk product import fails with "length ('-4') must be a non-negative value" — appears unrelated to imported fields

Bulk product import fails with "length ('-4') must be a non-negative value" — appears unrelated to imported fields

Joakim
Reply

Hi,

I've run into an issue with bulk product imports on one of our sites and would really appreciate any pointers — details below.

Environment: Dynamicweb 10.27.9

## Summary

Any bulk product import via the standard export/import wizard fails during
the "move data to main table" step with an internal ArgumentException about
a negative string length, even when the import only touches a single row and
a single, pre-existing, already-working field. The error surfaces while
building an index on the *EcomGroupRelations* temp table, not on the product
data being imported — which makes me suspect the group-relations staging
step that runs as part of every product import is hitting bad/oversized data
unrelated to the import content itself.

## Steps to reproduce

1. Export a product to Excel via Settings > Ecommerce > Products > Export
   (Quick export).
2. Edit only the `Number` (match key) and `ReferenceNumber` columns for a
   single existing product row.
3. Import the file back in with Import mode = "Update existing products".
4. Job fails.

This reproduces even with a single row and a field that already has other
values imported into it successfully via other jobs, so I don't think it's
about the specific row or field being updated.

## Error / log

    2026-08-19 10:20:13.2332|DataIntegration|INFORMATION|Starting import to temporary table for EcomProducts.
    2026-08-19 10:20:13.2332|DataIntegration|INFORMATION|Added 1 rows to temporary table for EcomProducts.
    2026-08-19 10:20:13.2337|DataIntegration|INFORMATION|Finished import to temporary table for EcomProducts.
    2026-08-19 10:20:13.2340|DataIntegration|INFORMATION|Starting update products information.
    2026-08-19 10:20:13.2784|DataIntegration|INFORMATION|Update products information finished.
    2026-08-19 10:20:13.4649|DataIntegration|ERROR|Error: failed to move data from temporary table [dbo.EcomProductsTempTableForBulkImport1] to main table [dbo.EcomProducts]. Exception: length ('-4') must be a non-negative value. (Parameter 'length') Actual value was -4. Sql query: CREATE UNIQUE NONCLUSTERED INDEX [DW_PK_EcomGroupRelations] ON [EcomGroupRelationsTempTableForBulkImport] ([GroupRelationsGroupId] ASC,[GroupRelationsParentId] ASC);  Stack:    at Dynamicweb.DataIntegration.Providers.EcomProvider.EcomDestinationWriter.MoveDataToMainTable(Mapping mapping, String tempTablePrefix, SqlTransaction sqlTransaction, Boolean updateOnly, Boolean insertOnly)    at Dynamicweb.DataIntegration.Providers.EcomProvider.EcomDestinationWriter.MoveDataToMainTables(String shop, SqlTransaction sqlTransaction, Boolean updateOnly, Boolean insertOnly)    at Dynamicweb.DataIntegration.Providers.EcomProvider.EcomProvider.RunJob(Job job)

## What I've already ruled out

- Not specific to any particular field being updated (reproduced with an
  existing field, `ReferenceNumber`, not a new one).
- Not specific to row count (fails identically with 1 row or 24 rows).
- Not a data-formatting issue in the import file (tested with minimal
  column sets, plain-text values, no special characters).
- The product temp-table import itself always completes successfully
  ("Update products information finished") — the failure happens strictly
  in the later `MoveDataToMainTables` step, specifically while indexing
  `EcomGroupRelationsTempTableForBulkImport`.

## Question

Since this happens on the `EcomGroupRelations` staging table regardless of
what's actually being imported, I'm wondering if it could be existing data in
`EcomGroupRelations` (e.g. a duplicate or oversized `[GroupId, ParentId]`
pair) tripping up the unique index build inside `EcomDestinationWriter`,
rather than anything about the import itself. Does this look familiar to
anyone, or is there a way to identify which row is causing the negative
length calculation?

Thanks in advance for any help — happy to provide more logs or
details if useful


Replies

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply

Hi Joakim,

could you check the column mapping configuration used for the group relations in this job — specifically whether any column is flagged as IsKeyColumn for that destination table?
It looks like if the mapping's configuration doesn't have any column flagged as a key for some reason, this may fail like in your case.
I have created the bug #29203 to fix that.

BR, Dmitrij

 
Joakim
Reply

I checked the actual job config behind this (the underlying
TemporaryConfig.xml for the export/import), and it looks like this
confirms your suspicion: EcomGroupRelations doesn't appear anywhere in
the job's table/column mappings at all. The only group-relations-adjacent
table present is EcomAssortmentGroupRelations (a different table), and
that one is correctly configured — isPrimaryKey="True" is set on both of
its actual key columns (AssortmentGroupRelationAssortmentID,
AssortmentGroupRelationGroupID).

So there's no key-column configuration for EcomGroupRelations for me to
check or adjust here, since that table was never part of this job's
user-facing mapping to begin with. That seems consistent with this being
internal to the bulk-import pipeline (staging/rebuilding an
EcomGroupRelationsTempTableForBulkImport behind the scenes for any
product import, regardless of what the job itself maps) rather than
something fixable from our side.

 
Dmitriy Benyuk Dynamicweb Employee
Dmitriy Benyuk
Reply
This post has been marked as an answer

Hi Joakim,
I was able to reproduce this problem on 10.27 and it is caused by not activated by default any of the Key Columns in the mapping screen.
It will be fixed in the next Dynamicweb 10.28 version, so the Key columns will be auto detected and activated by default. 
For now you can set the Key Columns manually in the mappings screen like that:

BR, Dmitrij

Votes for this answer: 1

 

You must be logged in to post in the forum