Softicles opened a new issue, #199:
URL: https://github.com/apache/airavata-django-portal/issues/199

   ### Describe the bug
   The `adpf-queue-settings-editor` web component crashes with a `TypeError` 
when its `queue` getter resolves to `null` (the selected queue hasn't loaded 
yet, or the stored `queue-name` doesn't match the compute resource's queues) 
while the `updateTotalCPUCount` / `updateNodeCount` store **actions** run.
   
   ### Error
   ```
   TypeError: can't access property "cpuPerNode", t.queue is undefined
       updateTotalCPUCount store.js
       totalCPUCount QueueSettingsEditor.vue
   TypeError: can't access property "cpuPerNode", t.queue is undefined
       updateNodeCount   store.js
       nodeCount         QueueSettingsEditor.vue
   ```
   
   ### Root cause
   
`django_airavata/apps/workspace/static/django_airavata_workspace/js/web-components/store.js`
 — the `updateTotalCPUCount` and `updateNodeCount` actions dereference 
`getters.queue.cpuPerNode` without a null check:
   
   ```js
   if (enableNodeCountToCpuCheck && getters.queue.cpuPerNode > 0) {
     // ...
   }
   ```
   
   But the `queue` getter can legitimately return `null`:
   
   ```js
   queue: (state, getters) =>
     getters.queues && getters.queueName
       ? getters.queues.find((q) => q.queueName === getters.queueName)
       : null,
   ```
   
   When the editor initializes from a run/experiment before the queue list has 
resolved (or with a `queue-name` that isn't among the compute resource's 
queues), `getters.queue` is `null`, and `getters.queue.cpuPerNode` throws — 
breaking the component (and any page embedding it).
   
   ### Steps to reproduce
   1. Embed `<adpf-queue-settings-editor>` (e.g. in a custom Django app or 
output-view) and initialize it with a `compute-resource-id` + `queue-name` 
before the queues finish loading, **or** with a `queue-name` not present in 
that resource's `batchQueues`.
   2. The `nodeCount` / `totalCPUCount` computed dispatch `updateNodeCount` / 
`updateTotalCPUCount`, which throw on `getters.queue.cpuPerNode`.
   
   ### Suggested fix
   Null-guard `getters.queue` in both actions:
   
   ```js
   if (enableNodeCountToCpuCheck && getters.queue && getters.queue.cpuPerNode > 
0) {
     // ...
   }
   ```
   
   ### Environment
   - `airavata-django-portal` workspace web components (`adpf` bundle).
   - Observed while embedding `adpf-queue-settings-editor` in a custom Django 
app (Django 3.2).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to