US-EPA-CAMD / easey-ui

Project Management repo for EPA Clean Air Markets Division (CAMD) Business Suite of applications
MIT License
0 stars 0 forks source link

Bug: Unable to import new component/analyzer range data #6217

Open esaber76 opened 4 months ago

esaber76 commented 4 months ago

When attempting to import a new component with analyzer range data, an API Communication error is returned.

image

The monitor-plan-api log shows a foreign key constraint error when doing an insert to the ANALYZER_RANGE table. In this example, it indicates that component_id "AAA" is not in the COMPONENT table. "AAA" is the component_identifier, not the component_id.

image

Steps to reproduce:

  1. Open & Checkout ORIS 564, 1.
  2. Revert to Official Record.
  3. Import attached file (Existing Hg component/analyzer range record ended for system 160, component ID 120. New Hg component/analyzer range record added for same system with component ID AAA.) MP Export - Curtis H. Stanton Energy Center, undefined (4-23-2024).json

Note: this is not an issue if a user were to make these changes in the workspace, export the changes, and immediately reimport the changes. It happens when starting with the official record.

esaber76 commented 4 months ago

@IkeC-dpc - let's wait until the ICAM changes are migrated and the bypass is off. We can then circle back if you are experiencing the same issues. I do think we may need to also add some CDX records to a database (on the CBS side) for your CDX dev account.

IkeC-dpc commented 3 months ago

@esaber76 In the attached .json file somehow the componentId "AAA" is incorrect and that's why it's throwing an Error. MP.Export.-.Curtis.H.Stanton.Energy.Center.undefined.4-23-2024.json

Question: Could you please confirm if this is a "valid" file to begin with? Just trying to rule out the possibility that we are not trying to "Import" an incompatible version of the file.

Please see the screenshot below for reference.

image
esaber76 commented 3 months ago

@IkeC-dpc - componentId AAA was added directly in the UI without issue at the time and then exported to json from the UI (this is and will be normal practice for real users; some users create the data, export it, and give it to other users to submit it). There were fairly recent changes to remove most of these fields from the monitoringSystemComponentData records as they are not relevant. Not really sure what issue you are running into though. I can try another example tomorrow or walk you through ending/adding a new component.

I'm not connected to the database right now, but component_id is a unique identifier. "AAA" is not. It's just the id a user chooses to give to the component.

esaber76 commented 3 months ago

@IkeC-dpc - Here is an updated file for ORIS 3, 6A. The monitoringSystemComponentData records were corrected on export based on another ticket, but the issue remains. It appears to me that component_identifier is being used for the insert to the analyzer_range table, which is not correct. component_id should be getting created on import in the component table and that id should be passed to the analyzer_range table.

MP Export - Barry, undefined (6-4-2024).json

IkeC-dpc commented 3 months ago

This was a Defect. Initially it took a few weeks to setup my local DEV environment first and then I had to bypass the permission check so that the "Import Data" button becomes visible so that I can debug the actual error. During troubleshooting I found that easey-monitor-plan-api was using ComponentRecordId where it should have been using ComponentId.

mxtomoto1 commented 3 months ago

Tester was able to successfully import the given file to dev and view the System Component with its Analyzer Ranges in the UI. (Modified MP evaluates, resulting in critical errors.)

Steps to reproduce: Open & Checkout ORIS 564, 1. Revert to Official Record. Import attached file (Existing Hg component/analyzer range record ended for system 160, component ID 120. New Hg component/analyzer range record added for same system with component ID AAA.) MP Export - Curtis H. Stanton Energy Center, undefined (4-23-2024).json

t_d1
esaber76 commented 3 months ago

@IkeC-dpc @yonatan-dp - this change appears to be creating duplicate analyzer range records for most any monitoring plan with components that have analyzer ranges. Ex. ORIS 3, CS0AAN, 1, 2. Just check out the monitoring plan, revert to official, export the monitoring plan, reimport it and evaluate. The following errors are returned.

image

If I look at one of the flagged components in the UI, a duplicate analyzer range record was added on import.

image

Note: I did not end/add any components in this example.

djw4erg commented 3 months ago

Matching Analyzer Range on Import in ECMPS 1.0

  1. First attempt, match on the following:
    • Component Id (DB Key)
    • Begin Date
    • Begin Hour
  2. Second attempt if first fails and End Date is not null, match on the following:
    • Component Id (DB Key)
    • End Date
    • End Hour

The Analyzer Range Code is not checked.

annalbrecht commented 2 months ago

Please test this scenario:

Config: ORIS 470, Location 1

Steps to Recreate the issue Login, navigate to the MP module, select and "Open & Checkout" the tested config. Export, Import, and evaluate the respective MP record. The evaluation returns critical errors. Download the Eval report and the critical error code COMPON-47-A, for multiple components (Component ID 106, 107, 108, etc.). Edit the MP json file to remove the data associated with componentID 106, save the file, import the file in the MP module, then evaluate the file. The evaluation returns critical errors, and the downloaded report indicates the Critical Error for ComponentID 106, even though the data was removed. Navigate to the MP module, revert to official record, then import and evaluate the file with the removed ComponentID 106 data. The Evaluation report no longer displays a critical error COMPON0-47-A for ComponentID 106.

mxtomoto1 commented 2 months ago

Please test this scenario:

Config: ORIS 470, Location 1

Steps to Recreate the issue Login, navigate to the MP module, select and "Open & Checkout" the tested config. Export, Import, and evaluate the respective MP record. The evaluation returns critical errors.

Critical errors were not produced during this evaluation (evaluating MP after reverting, exporting, and importing).

Download the Eval report and the critical error code COMPON-47-A, for multiple components (Component ID 106, 107, 108, etc.). Edit the MP json file to remove the data associated with componentID 106, save the file, import the file in the MP module, then evaluate the file. The evaluation returns critical errors, and the downloaded report indicates the Critical Error for ComponentID 106, even though the data was removed.

Deleted lines 1294-1312, 1963-1969, 2086-2092 from the JSON (references to componentId 106) and imported the edited JSON. Evaluation had no errors.

Resulting file used: MP Export - Comanche (470), undefined (7-17-2024)_Edit.json

Navigate to the MP module, revert to official record, then import and evaluate the file with the removed ComponentID 106 data. The Evaluation report no longer displays a critical error COMPON0-47-A for ComponentID 106.

Edited JSON was imported after reverting to official, and evaluation passed.

mxtomoto1 commented 1 month ago

MPs for locations with NOX, CO2, O2, SO2, HG components and analyzer ranges are able to be imported. MPs with created components / analyzer ranges evaluate with no issue (aside from unrelated, known issues).

Tests:

  1. For locations with at least one of the above 5 system components (that are not linked to multiple systems): ORIS 628, 1GTA (NOX, O2); ORIS 3, 6A (NOX, CO2); ORIS 564, 1 (HG, SO2)
  1. New components were also created for each of the 5 component types with analyzer ranges: ORIS 3, 6A (NOX, CO2); ORIS 628, 1GTA (O2); ORIS 298, 1 (HG, SO2). Steps taken:
t_d1

(screenshot for ORIS 3, 6A - creation of new NOX component with analyzer range)

bryanramirez1 commented 1 month ago

Ticket has been resolved successfully. MPs for locations with NOX, CO2, O2, SO2, HG components and analyzer ranges are able to be imported.

Tests:

  1. For locations with at least one of the above 5 system components (that are not linked to multiple systems): ORIS 628, 1GTA (NOX, O2); ORIS 3, 6A (NOX, CO2); ORIS 564, 1 (HG, SO2)
  1. New components were also created for each of the 5 component types with analyzer ranges: ORIS 3, 6A (NOX, CO2); ORIS 628, 1GTA (O2); ORIS 298, 1 (HG, SO2). Steps taken:
    • Was able to end existing component, analyzer range. Start new component / analyzer range on following hour, export to JSON, revert record to official, import new JSON, check for changes in UI, and evaluate successfully.