FlowFuse / FlowFuse/nr-assistant

The assistant created code which is not valid but the code can still be deployed and executed

Open
#43 1 comment 0 reactions 0 assignees View on GitHub
area:ff-expert needs-triage
Dominant language
JavaScript
Stars
5
Forks
5
Avg merge
2d 16h
Merged PRs (30d)
5

Description

### Current Behavior

Make the following request using the assistant link in the top right of FF NR.

```find the unique objects from the array in msg.payload using instanceId as the key and where created_at is the highest value. remove all other objects from the array, reorder the array by created_at DESC
```

The assistant returns code which I can deploy. If I open the function node the validator then picks up errors in the code so I can't redeploy.

This is the code it created.

```
//$PROMPT: find the unique objects from the array in msg.payload using instanceId as the key and where created_at is the highest value. remove all other objects from the array, reorder the array by created_at DESC
const uniqueObjects = {}

msg.payload.forEach(obj => {
const instanceId = obj.instanceId
if (!uniqueObjects[instanceId] || new Date(obj.created_at) > new Date(uniqueObjects[instanceId].created_at)) {
uniqueObjects[instanceId] = obj
}
})

msg.payload = Object.values(uniqueObjects).sort((a, b) => new Date(b.created_at) - new Date(a.created_at))

return msg
```

### Expected Behavior

The code which is created should be validated before it can be deployed.

### Steps To Reproduce

Use the prompt provided above.

### Environment

- FlowFuse version: v2.17.1-70ad837-202505281612.0
- Node.js version: v2.17.1-70ad837-202505281612.0
- npm version: FFC
- Platform/OS: Mac 15.5
- Browser: Chrome 136.0.7103.114

### Linked Customers

- Customer name and/or link to HubSpot contact

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the request through the assistant link in the top right of FF NR and inspect the generated code in the function node. Follow the validation and deployment path to determine where invalid generated code is accepted; done means the validator catches the error before deployment is allowed.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
ai, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.