frappe / frappe/agent

[Bug]: Donot expect clean output when running bench command

Open
#451 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
125
Forks
147
Avg merge
17h 20m
Merged PRs (30d)
17

Description

### Information about bug

When running agent job and when executing the bench command, do not load the data assuming that the data parsed will be a perfect json. Having custom apps in the folder and that could contain print statement could mess up the output of the bench commands. Say example in this case, we are getting installed apps.
Expected output:
bench --site hrms.frappe.cloud execute frappe.get_installed_apps
["frappe","erpnext"]

But for a user with custom apps and having logged prints in std out:
Actual output:
bench --site randomhrms.frappe.cloud execute frappe.get_installed_apps
✅ Duckwalk override: ...
["frappe", "erpnext", "insights", "greendigit"]

We can parse the output and figure out the expected pattern using regex and use that as input to run this job step. Otherwise the jobs will get failed.

https://github.com/frappe/agent/blob/bf88493ed9998c17fc6b42153577ef9f86ce564a/agent/site.py#L632-640

### Steps to Reproduce

Run a new site from backup job in bench with custom apps having stdout prints.

In my case, the output for the bench looked like the above one.

### Relevant log output / Stack trace / Full Error Message.

```shell

```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start at agent/site.py lines 632-640 and reproduce the backup job with a custom app that prints to stdout before the bench command's JSON output. Trace how the command output is currently consumed, then make the job tolerate the extra text and identify the expected JSON value. Done means the backup job succeeds with noisy custom-app output while still handling the clean example.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.