Bench new-site leads to error for tagged version of frappe

When I create a new site I get a weird mysql related error.

Steps to reproduce:

  1. bench init testv14 --frappe-branch=v14.23.0
  2. bench new-site test.sti

The outputs of the two commands are as follows:
bench init’s output

Setting Up Environment
$ python3 -m venv env
$ /home/frappe/frappe-framework/testv14/env/bin/python -m pip install --quiet --upgrade pip
Getting frappe
$ git clone --branch v14.23.0 --depth 1 --origin upstream
Cloning into 'frappe'...
remote: Enumerating objects: 3164, done.
remote: Counting objects: 100% (3164/3164), done.
remote: Compressing objects: 100% (2834/2834), done.
remote: Total 3164 (delta 428), reused 1248 (delta 231), pack-reused 0
Receiving objects: 100% (3164/3164), 16.00 MiB | 10.03 MiB/s, done.
Resolving deltas: 100% (428/428), done.
Note: switching to '5fe54eb3e1bd498a2c83154604675cb5a210a633'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

Installing frappe
$ /home/frappe/frappe-framework/testv14/env/bin/python -m pip install --quiet --upgrade -e /home/frappe/frappe-framework/testv14/apps/frappe 
$ yarn install
yarn install v1.22.19
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
warning " > @frappe/esbuild-plugin-postcss2@0.1.3" has unmet peer dependency "less@^4.x".
warning " > @frappe/esbuild-plugin-postcss2@0.1.3" has unmet peer dependency "stylus@^0.x".
warning Workspaces can only be enabled in private projects.
[5/5] Building fresh packages...
Done in 4.80s.
Found existing apps updating states...
$ bench build
Assets for Release v14.23.0 don't exist
✔ Application Assets Linked                                                                                                                                                                                        

yarn run v1.22.19
$ node esbuild --production --run-build-command
clean: postcss.plugin was deprecated. Migration guide:
clean: postcss.plugin was deprecated. Migration guide:
clean: postcss.plugin was deprecated. Migration guide:
clean: postcss.plugin was deprecated. Migration guide:
Browserslist: caniuse-lite is outdated. Please run:
  npx browserslist@latest --update-db
  Why you should do it regularly:
File                                                        Size

├─ bootstrap-4-web.bundle.22U72DEL.js                       1.73 Kb
├─ controls.bundle.I33VS4UY.js                              1226.73 Kb
├─ data_import_tools.bundle.ZHGGYJ52.js                     106.10 Kb
├─ desk.bundle.DHUPTRZP.js                                  1317.72 Kb
├─ dialog.bundle.TODLOC5R.js                                53.26 Kb
├─ form.bundle.QMORNZXU.js                                  153.74 Kb
├─ frappe-web.bundle.Q45J34V4.js                            823.82 Kb
├─ libs.bundle.YZMCKPNH.js                                  574.13 Kb
├─ list.bundle.NWWWZ4GT.js                                  185.38 Kb
├─ logtypes.bundle.7STJ7YLS.js                              0.73 Kb
├─ recorder.bundle.5AOEUOFD.js                              179.54 Kb
├─ report.bundle.IVJNDSMZ.js                                170.93 Kb
├─ user_profile_controller.bundle.YR6XHZRM.js               11.35 Kb
├─ video_player.bundle.UO3KNN5D.js                          120.59 Kb
├─ web_form.bundle.JNPS5JOB.js                              1561.17 Kb
├─ print_format_builder.bundle.KP4FAW42.js                  170.39 Kb
├─ build_events.bundle.L2HAVD4K.js                          11.62 Kb
└─ kanban_board.bundle.VCVKXCPT.js                          27.42 Kb

├─ desk.bundle.BC2DY2PR.css                                 545.25 Kb
├─ email.bundle.VWPPWCOA.css                                4.02 Kb
├─ login.bundle.GZH4HPLC.css                                23.56 Kb
├─ print.bundle.J5J6GQRM.css                                194.76 Kb
├─ print_format.bundle.2KVT5KVI.css                         177.61 Kb
├─ report.bundle.BVJMXO3T.css                               5.36 Kb
├─ web_form.bundle.PM2JSBGL.css                             14.73 Kb
└─ website.bundle.OPYA42VA.css                              420.35 Kb

├─ desk.bundle.32XRFCMC.css                                 545.50 Kb
├─ email.bundle.IKOXTWYX.css                                4.02 Kb
├─ login.bundle.QG3GYZMG.css                                23.56 Kb
├─ print.bundle.DJXEULYW.css                                194.91 Kb
├─ print_format.bundle.HKLWX62F.css                         177.72 Kb
├─ report.bundle.ARV3BZZT.css                               5.35 Kb
├─ web_form.bundle.XGWWODU7.css                             14.72 Kb
└─ website.bundle.2DGI6SBL.css                              420.50 Kb

 DONE  Total Build Time: 13.427s

 WARN  Cannot connect to redis_cache to update assets_json
 WARN  Cannot connect to redis_cache to update assets_json
 WARN  Cannot connect to redis_cache to update assets_json
Done in 17.06s.
SUCCESS: Bench testv14 initialized

bench new-site’s output

MySQL root password: 
Traceback (most recent call last):
  File "/home/frappe/.pyenv/versions/3.10.8/lib/python3.10/", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/frappe/.pyenv/versions/3.10.8/lib/python3.10/", line 86, in _run_code
    exec(code, run_globals)
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/utils/", line 109, in <module>
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/utils/", line 18, in main
  File "/home/frappe/frappe-framework/testv14/env/lib/python3.10/site-packages/click/", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/home/frappe/frappe-framework/testv14/env/lib/python3.10/site-packages/click/", line 782, in main
    rv = self.invoke(ctx)
  File "/home/frappe/frappe-framework/testv14/env/lib/python3.10/site-packages/click/", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-framework/testv14/env/lib/python3.10/site-packages/click/", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/frappe/frappe-framework/testv14/env/lib/python3.10/site-packages/click/", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/frappe/frappe-framework/testv14/env/lib/python3.10/site-packages/click/", line 610, in invoke
    return callback(*args, **kwargs)
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/commands/", line 74, in new_site
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/", line 80, in _new_site
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/", line 156, in install_db
    setup_database(force, source_sql, verbose, no_mariadb_socket)
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/database/", line 20, in setup_database
    return frappe.database.mariadb.setup_db.setup_database(
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/database/mariadb/", line 41, in setup_database
    if force or (db_name not in dbman.get_database_list()):
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/database/", line 49, in get_database_list
    return self.db.sql("SHOW DATABASES", pluck=True)
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/database/", line 260, in sql
    self.log_query(query, values, debug, explain)
  File "/home/frappe/frappe-framework/testv14/apps/frappe/frappe/database/mariadb/", line 203, in log_query
    self.last_query = query = self._cursor._last_executed
AttributeError: 'Cursor' object has no attribute '_last_executed'. Did you mean: '_check_executed'?