HR Dashboard "Server Error"

When I open the HR Dashboard view, I get the below server error;

“pymysql.err.OperationalError: (1054, “Unknown column ‘employment_type’ in ‘GROUP BY’”)”

Then I uninstall and reinstalled the HRMS module again, and then when I open the HR Dashboard view, I get a different server error;

“pymysql.err.OperationalError: (1054, “Unknown column ‘grade’ in ‘GROUP BY’”)”

Error Details:

App Versions

{
	"erpnext": "15.19.1",
	"frappe": "15.20.0",
	"hrms": "15.42.0",
	"non_profit": "0.0.1",
	"payments": "0.0.1",
	"woocommerce_fusion": "1.13.6"
}

Route

dashboard-view/Human Resource

Traceback

Traceback (most recent call last):
  File "apps/frappe/frappe/app.py", line 110, in application
    response = frappe.api.handle(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/__init__.py", line 49, in handle
    data = endpoint(**arguments)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/api/v1.py", line 36, in handle_rpc_call
    return frappe.handler.handle()
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 49, in handle
    data = execute_cmd(cmd)
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/handler.py", line 85, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1718, in call
    return fn(*args, **newargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/typing_validations.py", line 31, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/dashboard.py", line 26, in wrapper
    results = generate_and_cache_results(kwargs, function, cache_key, chart)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/utils/dashboard.py", line 41, in generate_and_cache_results
    results = function(
              ^^^^^^^^^
  File "apps/frappe/frappe/desk/doctype/dashboard_chart/dashboard_chart.py", line 131, in get
    chart_config = get_group_by_chart_config(chart, filters)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/desk/doctype/dashboard_chart/dashboard_chart.py", line 269, in get_group_by_chart_config
    data = frappe.get_list(
           ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/__init__.py", line 1982, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/db_query.py", line 191, in execute
    result = self.build_and_run()
             ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/model/db_query.py", line 232, in build_and_run
    return frappe.db.sql(
           ^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 234, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 153, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 322, in _query
    conn.query(q)
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 558, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 822, in _read_query_result
    result.read()
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 1200, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 772, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, "Unknown column 'employment_type' in 'GROUP BY'")

Request Data

{
	"type": "POST",
	"args": {
		"chart_name": "Employees by Type",
		"filters": "[[\"Employee\",\"status\",\"=\",\"Active\",false],[\"Employee\",\"company\",\"=\",\"digitalmarine24 (Demo)\"]]",
		"refresh": 1,
		"time_interval": null,
		"timespan": null,
		"from_date": null,
		"to_date": null,
		"heatmap_year": null
	},
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.doctype.dashboard_chart.dashboard_chart.get",
	"request_id": null
}

Response Data

{
	"exception": "pymysql.err.OperationalError: (1054, \"Unknown column 'employment_type' in 'GROUP BY'\")",
	"exc_type": "OperationalError"
}

Error:

Migrate the Bench using bench migrate and then clear the cache and restart the bench and check still error came

Things that I already tried;

bench --site [sitename] uninstall-app hrms --force
bench --site [sitename] migrate

bench remove-app hrms

bench get-app --branch version-15 hrms
bench --site [sitename] install-app hrms
bench --site [sitename] migrate
bench clear-cache
bench start again or bench restart

Try this and still not solve once run bench build command also

1 Like

I just ran the below commands

bench clear-cache
bench build

and it made things worse. I have installed the ERPNext instance in a Docker Container. Inside the docker container I ran the Bench Build. Now the UI doesn’t display correctly. How to solve this? It’s urgent

Also when I ran those commands, I got a warning message;

frappe@b28c1765dec1:~/frappe-bench$ bench build
Assets for Release /bin/sh: 1: Syntax error: "(" unexpected don't exist
✔ Application Assets Linked

You have not to run bench build in Docker
You have to Tell Initially that you are using Docker

Now,

1 Stop and Remove the Running Containers

docker compose down

2. Rebuild and Start Fresh Containers

docker compose up -d --build

3. Clear Redis Cache (if assets still broken)

  • Sometimes, Redis cache holds onto old asset references. Clear it by running:
docker exec -it <redis-cache-container-name> redis-cli FLUSHALL

4. Clear Frappe Cache

docker exec -it <frappe-container-name> bench clear-cache
docker exec -it <frappe-container-name> bench clear-website-cache

5. Refresh Your Browser
Use incognito mode or clear your browser cache to avoid loading old assets

I did like you said and now the Containers won’t run. Is there are any solution for that? I even tried building the container but no luck.

root@vmd155741:~# cd docker
root@vmd155741:~/docker# ls
erpnext  n8n  nginx-proxy-manager
root@vmd155741:~/docker# cd erpnext/
root@vmd155741:~/docker/erpnext# docker exec -it erpnext-backend-1 bench update --build
ERROR: Command 'basename $(git symbolic-ref -q HEAD)' returned non-zero exit status 1.
Traceback (most recent call last):
  File "/usr/local/bin/bench", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/usr/local/lib/python3.11/site-packages/bench/cli.py", line 132, in cli
    bench_command()
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bench/commands/update.py", line 59, in update
    update(
  File "/usr/local/lib/python3.11/site-packages/bench/utils/bench.py", line 457, in update
    validate_branch()
  File "/usr/local/lib/python3.11/site-packages/bench/utils/bench.py", line 644, in validate_branch
    branch = get_current_branch(app)
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bench/utils/app.py", line 175, in get_current_branch
    return get_cmd_output("basename $(git symbolic-ref -q HEAD)", cwd=repo_dir)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/bench/utils/__init__.py", line 228, in get_cmd_output
    output = subprocess.check_output(
             ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/subprocess.py", line 466, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'basename $(git symbolic-ref -q HEAD)' returned non-zero exit status 1.
INFO: A newer version of bench is available: 5.22.3 → 5.25.1

You not have to use bench build and bench updates in Docker Container

This are the tips you may follow while working with docker

  • Never use bench update inside containers built from official images. This will fail due to missing .git directories
  • Always backup before upgrades or downgrades. Downgrades are riskier and may cause schema conflicts—restoring from backup is the safest rollback
  • For custom app development: Use Git repositories and development containers with .git directories if you need to use bench update or branch switching
  • For multi-environment setups: Use separate Docker Compose files and databases for production, staging, etc., to isolate changes and test upgrades safely
1 Like

I’m new to configuring ERPNext with Docker, although I have experience setting up ERPNext on virtual machines. Your information was really helpful—thank you so much!

1 Like

How to run “bench build” in a docker environment? Is there a proper way to do it safely? I also want to know if that UI issue can be resolved using the below command (if there’s a permission related issue),

chmod 701 /home/<frappe-user>

Step-by-Step: Running bench build in Docker

1. Identify the Correct Container

  • You need to run bench build inside the container where the bench CLI and your site code reside.
  • This is usually named something like erpnext-backend-1, frappe-python-1, or similar, depending on your docker-compose.yml.

2. Enter the Container

docker exec -it <container_name> bash

Replace <container_name> with your backend container’s actual name

3. Navigate to the Bench Directory

Most setups use /workspace or /home/frappe/frappe-bench as the bench directory. For example:

cd /workspace
# or
cd /home/frappe/frappe-bench

4. Run the Build Command

bench build

This will compile and bundle all JS/CSS assets for all installed apps.


Best Practices and Considerations

  • Production Images: Official Docker images are built with assets already compiled. You only need to run bench build if you’ve made changes to assets or installed a new app that requires asset compilation.
  • Custom Development: For customizations, it’s common to mount your app code as a Docker volume and then run bench build after making changes.
  • Error Handling: If you encounter errors, ensure all dependencies (like Node.js, yarn, etc.) are installed in your image/container. Some minimal images may not have these tools.

About Permissions and the UI Issue

If you’re experiencing UI issues related to static assets, it’s sometimes due to file or directory permissions. You asked about:

chmod 701 /home/
  • 701 Permission Meaning: This sets the directory to be accessible (execute) by everyone, but only readable/writable by the owner.
  • Is This Safe? This is generally not recommended for production, as it can expose your user’s home directory to all users on the system, which is a security risk.
  • Proper Approach: Instead, ensure that the user running the container (typically frappe) owns all files and directories under /home/frappe and has at least 755 permissions on directories and 644 on files.

To fix permissions safely:

chown -R frappe:frappe /home/frappe
find /home/frappe -type d -exec chmod 755 {} \;
find /home/frappe -type f -exec chmod 644 {} \;

This ensures proper access for the application without exposing your system unnecessarily.


Can bench build Fix UI Issues?

  • Yes, if the issue is due to missing or outdated static assets. Running bench build will regenerate these assets, which can resolve many UI problems.
  • No, if the issue is due to permissions or missing files. In that case, fix permissions as shown above, then run bench build again.

In summary:

  • Run bench build inside the backend container after entering it with docker exec.
  • Use safe, standard permissions (755 for directories, 644 for files) instead of 701 on the home directory.
  • Rebuilding assets often resolves UI issues caused by stale or missing static files, but always check permissions if problems persist.

Follow this steps

Thanks alot for replying, I ran into the below error when trying to use ‘bench build’ command,

root@vmd155741:~# docker exec -it erpnext-backend-1 bash
frappe@67a8143a5042:~/frappe-bench$ bench build
Assets for Release /bin/sh: 1: Syntax error: "(" unexpected don't exist
✔ Application Assets Linked                                                                                 

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 114, in <module>
    main()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/utils/bench_helper.py", line 20, in main
    click.Group(commands=commands)(prog_name="bench")
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/apps/frappe/frappe/commands/utils.py", line 76, in build
    bundle(
  File "/home/frappe/frappe-bench/apps/frappe/frappe/build.py", line 252, in bundle
    check_node_executable()
  File "/home/frappe/frappe-bench/apps/frappe/frappe/build.py", line 276, in check_node_executable
    node_version = Version(subprocess.getoutput("node -v")[1:])
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/semantic_version/base.py", line 105, in __init__
    major, minor, patch, prerelease, build = self.parse(version_string, partial)
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/frappe/frappe-bench/env/lib/python3.11/site-packages/semantic_version/base.py", line 318, in parse
    raise ValueError('Invalid version string: %r' % version_string)
ValueError: Invalid version string: 'bin/sh: 1: node: Permission denied'

You have Install node js?

1 Like