Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

数据库数据插入bug #7

Open
fanyuxing20 opened this issue Jul 31, 2023 · 2 comments
Open

数据库数据插入bug #7

fanyuxing20 opened this issue Jul 31, 2023 · 2 comments
Labels
question Further information is requested

Comments

@fanyuxing20
Copy link

除去被强制下线以外对nonebot没有任何操作

希望可以解决报错问题,使得撤回功能正常使用

似乎是唯一键冲突,以下是全部报错信息

07-31 22:28:20 [SUCCESS] nonebot | OneBot V11 1926183056 | [message.private.friend]: Message 577202276 from 1912665242 '/echo test'
07-31 22:28:20 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot_plugin_autohelp.nonebot_plugin_autohelp)
[D 230731 22:28:20 nonebot_plugin_autohelp:61]  nonebot_plugin_autohelp entry
[D 230731 22:28:20 nonebot_plugin_autohelp:62] state: {'_prefix': {'command': ('echo',), 'raw_command': '/echo', 'command_arg': [MessageSegment(type='text', data={'text': 'test'})], 'command_start': '/', 'command_whitespace': ' '}}
[D 230731 22:28:20 nonebot_plugin_autohelp:65] check time interval: 1690813700.4
[D 230731 22:28:20 nonebot_plugin_autohelp:72] msg: /echo test
[D 230731 22:28:20 nonebot_plugin_autohelp:75] patt.findall(msg) False, return...
07-31 22:28:20 [INFO] nonebot | Matcher(type='message', module=nonebot_plugin_autohelp.nonebot_plugin_autohelp) running complete
07-31 22:28:20 [INFO] nonebot | Event will be handled by Matcher(type='message', module=nonebot.plugins.echo)
07-31 22:28:20 [ERROR] nonebot | Error when running CalledAPI hook. Running cancelled!
Traceback (most recent call last):
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\engine\base.py", line 1965, in _exec_single_context
    self.dialect.do_execute(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\engine\default.py", line 921, in do_execute
    cursor.execute(statement, parameters)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\dialects\sqlite\aiosqlite.py", line 113, in execute
    self._adapt_connection._handle_exception(error)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\dialects\sqlite\aiosqlite.py", line 263, in _handle_exception
    raise error
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\dialects\sqlite\aiosqlite.py", line 95, in execute
    self.await_(_cursor.execute(operation, parameters))
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 125, in await_only
    return current.driver.switch(awaitable)  # type: ignore[no-any-return]
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 185, in greenlet_spawn
    value = await result
  File "C:\conda\envs\nonebot\lib\site-packages\aiosqlite\cursor.py", line 48, in execute
    await self._execute(self._cursor.execute, sql, parameters)
  File "C:\conda\envs\nonebot\lib\site-packages\aiosqlite\cursor.py", line 40, in _execute
    return await self._conn._execute(fn, *args, **kwargs)
  File "C:\conda\envs\nonebot\lib\site-packages\aiosqlite\core.py", line 133, in _execute
    return await future
  File "C:\conda\envs\nonebot\lib\site-packages\aiosqlite\core.py", line 106, in run
    result = function()
sqlite3.IntegrityError: UNIQUE constraint failed: nonebot_plugin_follow_withdraw_followmessage.message_id

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<string>", line 17, in <module>
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\__init__.py", line 333, in run
    get_driver().run(*args, **kwargs)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\drivers\fastapi.py", line 199, in run
    uvicorn.run(
  File "C:\conda\envs\nonebot\lib\site-packages\uvicorn\main.py", line 587, in run
    server.run()
  File "C:\conda\envs\nonebot\lib\site-packages\uvicorn\server.py", line 61, in run
    return asyncio.run(self.serve(sockets=sockets))
  File "C:\conda\envs\nonebot\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\conda\envs\nonebot\lib\asyncio\base_events.py", line 636, in run_until_complete
    self.run_forever()
  File "C:\conda\envs\nonebot\lib\asyncio\windows_events.py", line 321, in run_forever
    super().run_forever()
  File "C:\conda\envs\nonebot\lib\asyncio\base_events.py", line 603, in run_forever
    self._run_once()
  File "C:\conda\envs\nonebot\lib\asyncio\base_events.py", line 1909, in _run_once
    handle._run()
  File "C:\conda\envs\nonebot\lib\asyncio\events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\message.py", line 467, in check_and_run_matcher
    await _run_matcher(
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\message.py", line 419, in _run_matcher
    await matcher.run(bot, event, state, stack, dependency_cache)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\internal\matcher\matcher.py", line 759, in run
    await self.simple_run(bot, event, state, stack, dependency_cache)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\internal\matcher\matcher.py", line 734, in simple_run
    await handler(
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\dependencies\__init__.py", line 108, in __call__
    return await cast(Callable[..., Awaitable[R]], self.call)(**values)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\plugins\echo.py", line 22, in handle_echo
    await echo.send(message=message)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\internal\matcher\matcher.py", line 467, in send
    return await bot.send(event=event, message=_message, **kwargs)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\adapters\onebot\v11\bot.py", line 220, in send
    return await self.__class__.send_handler(self, event, message, **kwargs)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot\adapters\onebot\v11\bot.py", line 174, in send
    return await bot.send_msg(**params)
> File "C:\conda\envs\nonebot\lib\site-packages\nonebot\internal\adapter\bot.py", line 107, in call_api
    await asyncio.gather(*coros)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot_plugin_follow_withdraw\__init__.py", line 87, in handle_save_message
    await save_message(adapter_name, origin_message, message)
  File "C:\conda\envs\nonebot\lib\site-packages\nonebot_plugin_follow_withdraw\model.py", line 81, in save_message
    await session.commit()
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\ext\asyncio\session.py", line 944, in commit
    await greenlet_spawn(self.sync_session.commit)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 192, in greenlet_spawn
    result = context.switch(value)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\session.py", line 1920, in commit
    trans.commit(_to_root=True)
  File "<string>", line 2, in commit
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\session.py", line 1236, in commit
    self._prepare_impl()
  File "<string>", line 2, in _prepare_impl
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\state_changes.py", line 139, in _go
    ret_value = fn(self, *arg, **kw)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\session.py", line 1211, in _prepare_impl
    self.session.flush()
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\session.py", line 4163, in flush
    self._flush(objects)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\session.py", line 4298, in _flush
    with util.safe_reraise():
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\util\langhelpers.py", line 147, in __exit__
    raise exc_value.with_traceback(exc_tb)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\session.py", line 4259, in _flush
    flush_context.execute()
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 466, in execute
    rec.execute(self)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 642, in execute
    util.preloaded.orm_persistence.save_obj(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\persistence.py", line 93, in save_obj
    _emit_insert_statements(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\orm\persistence.py", line 1043, in _emit_insert_statements
    result = connection.execute(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\engine\base.py", line 1412, in execute
    return meth(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\sql\elements.py", line 483, in _execute_on_connection
    return connection._execute_clauseelement(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\engine\base.py", line 1635, in _execute_clauseelement
    ret = self._execute_context(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\engine\base.py", line 1844, in _execute_context
    return self._exec_single_context(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\engine\base.py", line 1984, in _exec_single_context
    self._handle_dbapi_exception(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\engine\base.py", line 2339, in _handle_dbapi_exception
    raise sqlalchemy_exception.with_traceback(exc_info[2]) from e
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\engine\base.py", line 1965, in _exec_single_context
    self.dialect.do_execute(
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\engine\default.py", line 921, in do_execute
    cursor.execute(statement, parameters)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\dialects\sqlite\aiosqlite.py", line 113, in execute
    self._adapt_connection._handle_exception(error)
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\dialects\sqlite\aiosqlite.py", line 263, in _handle_exception
    raise error
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\dialects\sqlite\aiosqlite.py", line 95, in execute
    self.await_(_cursor.execute(operation, parameters))
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 125, in await_only
    return current.driver.switch(awaitable)  # type: ignore[no-any-return]
  File "C:\conda\envs\nonebot\lib\site-packages\sqlalchemy\util\_concurrency_py3k.py", line 185, in greenlet_spawn
    value = await result
  File "C:\conda\envs\nonebot\lib\site-packages\aiosqlite\cursor.py", line 48, in execute
    await self._execute(self._cursor.execute, sql, parameters)
  File "C:\conda\envs\nonebot\lib\site-packages\aiosqlite\cursor.py", line 40, in _execute
    return await self._conn._execute(fn, *args, **kwargs)
  File "C:\conda\envs\nonebot\lib\site-packages\aiosqlite\core.py", line 133, in _execute
    return await future
  File "C:\conda\envs\nonebot\lib\site-packages\aiosqlite\core.py", line 106, in run
    result = function()
sqlalchemy.exc.IntegrityError: (sqlite3.IntegrityError) UNIQUE constraint failed: nonebot_plugin_follow_withdraw_followmessage.message_id
[SQL: INSERT INTO nonebot_plugin_follow_withdraw_followmessage (message_id, adapter_name, channel_id, origin_message_id) VALUES (?, ?, ?, ?)]
[parameters: ('1255734984', 'OneBot V11', None, '577202276')]
(Background on this error at: https://sqlalche.me/e/20/gkpj)
07-31 22:28:21 [INFO] nonebot | Matcher(type='message', module=nonebot.plugins.echo) running complete
@CMHopeSunshine
Copy link
Owner

正常使用下,我想不到什么情况go-cqhttp的message_id会不唯一

@CMHopeSunshine
Copy link
Owner

可以先用指令清除消息记录删除数据库记录

@CMHopeSunshine CMHopeSunshine added the question Further information is requested label Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants