[GH-ISSUE #184] Import Scheme rule "If object is not found" = "Treat as Error" is ignored (PriceHistory import) #95

Closed
opened 2026-03-03 11:58:50 +03:00 by kerem · 4 comments
Owner

Originally created by @sergeiosipov on GitHub (Feb 18, 2026).
Original GitHub issue: https://github.com/finmars-platform/finmars-core/issues/184

Originally assigned to: @paktusov on GitHub.

Bug: Import Scheme rule "If object is not found" = Treat as Error is ignored (PriceHistory import)

Summary

In Simple Entity Import Scheme Manager (v2), setting Import Rules → If object is not found = Treat as Error does not prevent booking.
When an object referenced by an input field is missing (e.g., Pricing Policy), the import still succeeds and the item is booked using a default value.

You can see the setting in com.finmars.standard-import-from-file:instruments.pricehistory:prices_prc:
Image


Environment

  • PMS Core: latest
  • Import scheme user code: com.finmars.standard-import-from-file:instruments.pricehistory:prices_prc
  • UI: Simple Entity Import Scheme Manager (v2)

Steps to Reproduce

  1. Install latest PMS Core
  2. Open Import → Import Data from File
  3. Select entity
    Price History
  4. Select Import Scheme
    STD - PRC
  5. Import a row with a non-existing Pricing Policy:
[
    {
        "Accrued Price": 0,
        "Date": "2011-08-05T00:00:00",
        "Factor": 1,
        "Instrument ID": "-",
        "Modified Duration": 0,
        "Pricing Policy": "com.finmars.standard-pricing:doesnt_exist",
        "Principal Price": 1,
        "YTM": 0,
        "is_temporary_price": false,
        "long_delta": 0,
        "short_delta": 0
    }
]
Image

Actual Result

  • "com.finmars.standard-pricing:doesnt_exist" is not found
  • Key pricing_policy is removed from final_inputs
  • Error message is formed:
    None Relation model error: KeyError('pricing_policy')
  • Import finishes with status: "success"
  • Price is booked (default pricing policy is applied)

Example response:

{
  "error_message": "None Relation model error: KeyError('pricing_policy')",
  "final_inputs": {
    "accrued_price": 0,
    "date": "2011-08-05",
    "factor": 1,
    "instrument": "-",
    "principal_price": 1
  },
  "message": "Item Imported pricehistory",
  "status": "success"
}

Expected Result

  • "com.finmars.standard-pricing:doesnt_exist" is not found
  • Key pricing_policy is removed from final_inputs
  • Error message is formed
  • Import result must be status: "error"
  • Price must NOT be booked

Notes

It appears that when a referenced relation is not found:

  • the field is removed from final_inputs
  • an error message is generated
  • but the pipeline continues and applies defaults

The "Treat as Error" rule does not escalate the failure to an error status and does not stop booking.

Originally created by @sergeiosipov on GitHub (Feb 18, 2026). Original GitHub issue: https://github.com/finmars-platform/finmars-core/issues/184 Originally assigned to: @paktusov on GitHub. ## Bug: Import Scheme rule **"If object is not found" = Treat as Error** is ignored (PriceHistory import) ### Summary In **Simple Entity Import Scheme Manager (v2)**, setting **Import Rules → If object is not found = Treat as Error** does not prevent booking. When an object referenced by an input field is missing (e.g., Pricing Policy), the import still succeeds and the item is booked using a default value. You can see the setting in `com.finmars.standard-import-from-file:instruments.pricehistory:prices_prc`: <img width="800" alt="Image" src="https://github.com/user-attachments/assets/08f1dbe1-fb67-4885-a4d0-d79a5de869b1" /> --- ### Environment - PMS Core: latest - Import scheme user code: `com.finmars.standard-import-from-file:instruments.pricehistory:prices_prc` - UI: Simple Entity Import Scheme Manager (v2) --- ### Steps to Reproduce 1. Install latest PMS Core 2. Open **Import → Import Data from File** 3. Select entity `Price History` 4. Select Import Scheme **STD - PRC** 5. Import a row with a non-existing Pricing Policy: ```json [ { "Accrued Price": 0, "Date": "2011-08-05T00:00:00", "Factor": 1, "Instrument ID": "-", "Modified Duration": 0, "Pricing Policy": "com.finmars.standard-pricing:doesnt_exist", "Principal Price": 1, "YTM": 0, "is_temporary_price": false, "long_delta": 0, "short_delta": 0 } ] ``` <img width="800" alt="Image" src="https://github.com/user-attachments/assets/70e9d109-47d9-454a-9125-2fd79dd84252" /> --- ### Actual Result - `"com.finmars.standard-pricing:doesnt_exist"` is not found - Key `pricing_policy` is removed from `final_inputs` - Error message is formed: `None Relation model error: KeyError('pricing_policy')` - Import finishes with **`status: "success"`** - **Price is booked** (default pricing policy is applied) Example response: ```json { "error_message": "None Relation model error: KeyError('pricing_policy')", "final_inputs": { "accrued_price": 0, "date": "2011-08-05", "factor": 1, "instrument": "-", "principal_price": 1 }, "message": "Item Imported pricehistory", "status": "success" } ``` --- ### Expected Result - `"com.finmars.standard-pricing:doesnt_exist"` is not found - Key `pricing_policy` is removed from `final_inputs` - Error message is formed - Import result **must be `status: "error"`** - **Price must NOT be booked** --- ### Notes It appears that when a referenced relation is not found: - the field is removed from `final_inputs` - an error message is generated - but the pipeline continues and applies defaults The **"Treat as Error"** rule does not escalate the failure to an error status and does not stop booking.
kerem closed this issue 2026-03-03 11:58:50 +03:00
Author
Owner

@falendary commented on GitHub (Feb 18, 2026):

I assume error somewhere here
https://github.com/finmars-platform/finmars-core/blob/main/poms/csv_import/handlers.py#L1602

@paktusov

<!-- gh-comment-id:3921482441 --> @falendary commented on GitHub (Feb 18, 2026): I assume error somewhere here https://github.com/finmars-platform/finmars-core/blob/main/poms/csv_import/handlers.py#L1602 @paktusov
Author
Owner

@sergeiosipov commented on GitHub (Feb 24, 2026):

Tested, seems like price history import is working how it was intended now.

{
  "error_message": null,
  "file_name": null,
  "items": [
    {
      "error_message": " Relation not found: pricing_policy=com.finmars.standard-pricing:doesnt_exist",
      "file_inputs": {
        "Accrued Price": 0,
        "Date": "2011-08-05T00:00:00",
        "Factor": 1,
        "Instrument ID": "DE000BU0E055",
        "Modified Duration": 0,
        "Pricing Policy": "com.finmars.standard-pricing:doesnt_exist",
        "Principal Price": 1,
        "YTM": 0,
        "is_temporary_price": false,
        "long_delta": 0,
        "short_delta": 0
      },
      "final_inputs": {
        "accrued_price": 0,
        "date": "2011-08-05",
        "factor": 1,
        "instrument": "DE000BU0E055",
        "principal_price": 1
      },
      "imported_items": null,
      "message": "",
      "row_number": 1,
      "status": "error"
    },
    {
      "error_message": null,
      "file_inputs": {
        "Accrued Price": 0,
        "Date": "2011-08-06T00:00:00",
        "Factor": 1,
        "Instrument ID": "DE000BU0E055",
        "Modified Duration": 0,
        "Pricing Policy": "com.finmars.standard-pricing:standard",
        "Principal Price": 1,
        "YTM": 0,
        "is_temporary_price": false,
        "long_delta": 0,
        "short_delta": 0
      },
      "final_inputs": {
        "accrued_price": 0,
        "date": "2011-08-06",
        "factor": 1,
        "instrument": "DE000BU0E055",
        "pricing_policy": "com.finmars.standard-pricing:standard",
        "principal_price": 1
      },
      "imported_items": null,
      "message": "Item Imported pricehistory",
      "row_number": 2,
      "status": "success"
    },
    {
      "error_message": " Relation not found: instrument=DE000BU0E055notesxist",
      "file_inputs": {
        "Accrued Price": 0,
        "Date": "2011-08-06T00:00:00",
        "Factor": 1,
        "Instrument ID": "DE000BU0E055notesxist",
        "Modified Duration": 0,
        "Pricing Policy": "com.finmars.standard-pricing:standard",
        "Principal Price": 1,
        "YTM": 0,
        "is_temporary_price": false,
        "long_delta": 0,
        "short_delta": 0
      },
      "final_inputs": {
        "accrued_price": 0,
        "date": "2011-08-06",
        "factor": 1,
        "pricing_policy": "com.finmars.standard-pricing:standard",
        "principal_price": 1
      },
      "imported_items": null,
      "message": "",
      "row_number": 3,
      "status": "error"
    }
  ],
  "processed_rows": 1,
  "reports": null,
  "scheme": {
    "delimiter": ",",
    "error_handler": "continue",
    "id": 5,
    "missing_data_handler": "throw_error",
    "name": "STD  - PRC",
    "user_code": "com.finmars.standard-import-from-file:instruments.pricehistory:prices_prc"
  },
  "task": {
    "id": 297,
    "status": "P",
    "type": "simple_import"
  },
  "total_rows": 3
}
<!-- gh-comment-id:3951375152 --> @sergeiosipov commented on GitHub (Feb 24, 2026): Tested, seems like price history import is working how it was intended now. ```json { "error_message": null, "file_name": null, "items": [ { "error_message": " Relation not found: pricing_policy=com.finmars.standard-pricing:doesnt_exist", "file_inputs": { "Accrued Price": 0, "Date": "2011-08-05T00:00:00", "Factor": 1, "Instrument ID": "DE000BU0E055", "Modified Duration": 0, "Pricing Policy": "com.finmars.standard-pricing:doesnt_exist", "Principal Price": 1, "YTM": 0, "is_temporary_price": false, "long_delta": 0, "short_delta": 0 }, "final_inputs": { "accrued_price": 0, "date": "2011-08-05", "factor": 1, "instrument": "DE000BU0E055", "principal_price": 1 }, "imported_items": null, "message": "", "row_number": 1, "status": "error" }, { "error_message": null, "file_inputs": { "Accrued Price": 0, "Date": "2011-08-06T00:00:00", "Factor": 1, "Instrument ID": "DE000BU0E055", "Modified Duration": 0, "Pricing Policy": "com.finmars.standard-pricing:standard", "Principal Price": 1, "YTM": 0, "is_temporary_price": false, "long_delta": 0, "short_delta": 0 }, "final_inputs": { "accrued_price": 0, "date": "2011-08-06", "factor": 1, "instrument": "DE000BU0E055", "pricing_policy": "com.finmars.standard-pricing:standard", "principal_price": 1 }, "imported_items": null, "message": "Item Imported pricehistory", "row_number": 2, "status": "success" }, { "error_message": " Relation not found: instrument=DE000BU0E055notesxist", "file_inputs": { "Accrued Price": 0, "Date": "2011-08-06T00:00:00", "Factor": 1, "Instrument ID": "DE000BU0E055notesxist", "Modified Duration": 0, "Pricing Policy": "com.finmars.standard-pricing:standard", "Principal Price": 1, "YTM": 0, "is_temporary_price": false, "long_delta": 0, "short_delta": 0 }, "final_inputs": { "accrued_price": 0, "date": "2011-08-06", "factor": 1, "pricing_policy": "com.finmars.standard-pricing:standard", "principal_price": 1 }, "imported_items": null, "message": "", "row_number": 3, "status": "error" } ], "processed_rows": 1, "reports": null, "scheme": { "delimiter": ",", "error_handler": "continue", "id": 5, "missing_data_handler": "throw_error", "name": "STD - PRC", "user_code": "com.finmars.standard-import-from-file:instruments.pricehistory:prices_prc" }, "task": { "id": 297, "status": "P", "type": "simple_import" }, "total_rows": 3 } ```
Author
Owner

@sergeiosipov commented on GitHub (Feb 24, 2026):

Tested, seems like currency history import is working how it was intended as well.

{
  "error_message": null,
  "file_name": null,
  "items": [
    {
      "error_message": " Relation not found: pricing_policy=com.finmars.standard-pricing:doesnt_exist",
      "file_inputs": {
        "Currency ID": "USD",
        "Date": "2011-08-05T00:00:00",
        "FX Rate": 0,
        "Pricing Policy": "com.finmars.standard-pricing:doesnt_exist"
      },
      "final_inputs": {
        "currency": "USD",
        "date": "2011-08-05",
        "fx_rate": 0
      },
      "imported_items": null,
      "message": "",
      "row_number": 1,
      "status": "error"
    },
    {
      "error_message": " Relation not found: currency=not_exist",
      "file_inputs": {
        "Currency ID": "not_exist",
        "Date": "2011-08-05T00:00:00",
        "FX Rate": 0,
        "Pricing Policy": "com.finmars.standard-pricing:standard"
      },
      "final_inputs": {
        "date": "2011-08-05",
        "fx_rate": 0,
        "pricing_policy": "com.finmars.standard-pricing:standard"
      },
      "imported_items": null,
      "message": "",
      "row_number": 2,
      "status": "error"
    },
    {
      "error_message": null,
      "file_inputs": {
        "Currency ID": "USD",
        "Date": "2011-08-05T00:00:00",
        "FX Rate": 0,
        "Pricing Policy": "com.finmars.standard-pricing:standard"
      },
      "final_inputs": {
        "currency": "USD",
        "date": "2011-08-05",
        "fx_rate": 0,
        "pricing_policy": "com.finmars.standard-pricing:standard"
      },
      "imported_items": null,
      "message": "Item Imported currencyhistory",
      "row_number": 3,
      "status": "success"
    }
  ],
  "processed_rows": 1,
  "reports": null,
  "scheme": {
    "delimiter": ",",
    "error_handler": "break",
    "id": 3,
    "missing_data_handler": "throw_error",
    "name": "STD - FX RATE",
    "user_code": "com.finmars.standard-import-from-file:currencies.currencyhistory:fx_rate"
  },
  "task": {
    "id": 298,
    "status": "P",
    "type": "simple_import"
  },
  "total_rows": 3
}
<!-- gh-comment-id:3951413289 --> @sergeiosipov commented on GitHub (Feb 24, 2026): Tested, seems like currency history import is working how it was intended as well. ```json { "error_message": null, "file_name": null, "items": [ { "error_message": " Relation not found: pricing_policy=com.finmars.standard-pricing:doesnt_exist", "file_inputs": { "Currency ID": "USD", "Date": "2011-08-05T00:00:00", "FX Rate": 0, "Pricing Policy": "com.finmars.standard-pricing:doesnt_exist" }, "final_inputs": { "currency": "USD", "date": "2011-08-05", "fx_rate": 0 }, "imported_items": null, "message": "", "row_number": 1, "status": "error" }, { "error_message": " Relation not found: currency=not_exist", "file_inputs": { "Currency ID": "not_exist", "Date": "2011-08-05T00:00:00", "FX Rate": 0, "Pricing Policy": "com.finmars.standard-pricing:standard" }, "final_inputs": { "date": "2011-08-05", "fx_rate": 0, "pricing_policy": "com.finmars.standard-pricing:standard" }, "imported_items": null, "message": "", "row_number": 2, "status": "error" }, { "error_message": null, "file_inputs": { "Currency ID": "USD", "Date": "2011-08-05T00:00:00", "FX Rate": 0, "Pricing Policy": "com.finmars.standard-pricing:standard" }, "final_inputs": { "currency": "USD", "date": "2011-08-05", "fx_rate": 0, "pricing_policy": "com.finmars.standard-pricing:standard" }, "imported_items": null, "message": "Item Imported currencyhistory", "row_number": 3, "status": "success" } ], "processed_rows": 1, "reports": null, "scheme": { "delimiter": ",", "error_handler": "break", "id": 3, "missing_data_handler": "throw_error", "name": "STD - FX RATE", "user_code": "com.finmars.standard-import-from-file:currencies.currencyhistory:fx_rate" }, "task": { "id": 298, "status": "P", "type": "simple_import" }, "total_rows": 3 } ```
Author
Owner

@sergeiosipov commented on GitHub (Feb 24, 2026):

Have enough evidence to consider the issue to be closed.

<!-- gh-comment-id:3951421067 --> @sergeiosipov commented on GitHub (Feb 24, 2026): Have enough evidence to consider the issue to be closed.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/finmars-core#95
No description provided.