Open restarbuck101 opened 3 months ago
Looks like your first issue -- we aim to respond to issues as quickly as possible. In the meantime, check out our documentation here: http://caldera.readthedocs.io/
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days
Describe the bug Build failed with error Cannot assign to "envs" because it is a constant script:/home/geeseman/caldera/plugins/magma/src/plugins/builder/views/builder.vue?id=0:9:4: ERROR: Cannot assign to "envs" because it is a constant vite v2.9.15 dev server running at: The issue arises from attempting to reassign a value to a constant variable that was intended to be a reactive reference.
To Reproduce Executing Caldera with the following 4 commands in your terminal. 1.git clone https://github.com/mitre/caldera.git --recursive 2.cd caldera 3.pip3 install -r requirements.txt 4.python3 server.py --insecure --build
Expected behavior The expected behavior was that the envs reactive reference would be updated with the new value fetched from $api.get("/plugin/builder/environment"), allowing the component to react to the updated state. The process should not result in build errors, and the development server should start without issues.
Screenshots Build failed with 2 errors: script:/caldera/plugins/builder/gui/views/builder.vue?id=0:9:4: ERROR: Cannot assign to "envs" because it is a constant script:/home/geeseman/caldera/plugins/magma/src/plugins/builder/views/builder.vue?id=0:9:4: ERROR: Cannot assign to "envs" because it is a constant vite v2.9.15 dev server running at: > Local: http://localhost:3000/
ready in 261ms.
✘ [ERROR] Cannot assign to "envs" because it is a constant
The symbol "envs" was declared a constant here:
✘ [ERROR] Cannot assign to "envs" because it is a constant
The symbol "envs" was declared a constant here:
Desktop (please complete the following information):
Additional context This issue is highlighted in both instances within your project's Vue component files:
/caldera/plugins/builder/gui/views/builder.vue /caldera/plugins/magma/src/plugins/builder/views/builder.vue
Proposed solution: Update a reactive reference by accessing its .value property, not by reassigning the reference itself. This approach adheres to the Vue.js Composition API's design, allowing you to maintain reactivity while conforming to JavaScript's const constraints.
For the builder.vue and any similar files , update the code as follows
Before: const envs = ref();envs = await $api.get("/plugin/builder/environment");
After: const envs = ref();envs.value = await $api.get("/plugin/builder/environment");
By modifying the code as suggested, you update the reactive state of envs without attempting to reassign the const, thereby avoiding the build errors.