press icon indicating copy to clipboard operation
press copied to clipboard

Don't allow adding duplicate apps in marketplace

Open BreadGenie opened this issue 1 year ago • 1 comments

image While adding duplicate apps it throws an error and does a toast with empty message

Traceback (most recent call last):

File "apps/frappe/frappe/model/base_[document.py](http://document.py/)", line 558, in db_insert

frappe.db.sql(

File "apps/frappe/frappe/database/[database.py](http://database.py/)", line 224, in sql

self._cursor.execute(query, values)

File "env/lib/python3.10/site-packages/pymysql/[cursors.py](http://cursors.py/)", line 153, in execute

result = self._query(query)

File "env/lib/python3.10/site-packages/pymysql/[cursors.py](http://cursors.py/)", line 322, in _query

conn.query(q)

File "env/lib/python3.10/site-packages/pymysql/[connections.py](http://connections.py/)", line 558, in query

self._affected_rows = self._read_query_result(unbuffered=unbuffered)

File "env/lib/python3.10/site-packages/pymysql/[connections.py](http://connections.py/)", line 822, in readquery_result

[result.read](http://result.read/)()

File "env/lib/python3.10/site-packages/pymysql/[connections.py](http://connections.py/)", line 1200, in read

first_packet = self.connection._read_packet()

File "env/lib/python3.10/site-packages/pymysql/[connections.py](http://connections.py/)", line 772, in readpacket

packet.raise_for_error()

File "env/lib/python3.10/site-packages/pymysql/[protocol.py](http://protocol.py/)", line 221, in raise_for_error

err.raise_mysql_exception(self._data)

File "env/lib/python3.10/site-packages/pymysql/[err.py](http://err.py/)", line 143, in raise_mysql_exception

raise errorclass(errno, errval)

pymysql.err.IntegrityError: (1062, "Duplicate entry 'lending' for key 'PRIMARY'")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "apps/frappe/frappe/[app.py](http://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](http://v1.py/)", line 36, in handle_rpc_call

return frappe.handler.handle()

File "apps/frappe/frappe/[handler.py](http://handler.py/)", line 49, in handle

data = execute_cmd(cmd)

File "apps/frappe/frappe/[handler.py](http://handler.py/)", line 85, in execute_cmd

return [frappe.call](http://frappe.call/)(method, **frappe.form_dict)

File "apps/frappe/frappe/__init__.py", line 1795, in call

return fn(*args, **newargs)

File "apps/frappe/frappe/utils/typing_[validations.py](http://validations.py/)", line 31, in wrapper

return func(*args, **kwargs)

File "apps/press/press/api/[client.py](http://client.py/)", line 193, in insert

_doc.insert()

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 283, in insert

[self.run](http://self.run/)_method("before_insert")

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 964, in run_method

out = Document.hook(fn)(self, args, *kwargs)

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 1324, in composer

return composed(self, method, args, *kwargs)

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 1306, in runner

add_to_return_value(self, fn(self, args, *kwargs))

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 961, in fn

return method_object(*args, **kwargs)

File "apps/press/press/press/doctype/marketplace_app/marketplace_[app.py](http://app.py/)", line 132, in before_insert

self.create_app_and_source_if_needed()

File "apps/press/press/press/doctype/marketplace_app/marketplace_[app.py](http://app.py/)", line 150, in create_app_and_source_if_needed

app_doc = new_app_doc([self.name](http://self.name/), self.title)

File "apps/press/press/press/doctype/app/[app.py](http://app.py/)", line 82, in new_app

app = frappe.get_doc({"doctype": "App", "name": name, "title": title}).insert()

File "apps/frappe/frappe/model/[document.py](http://document.py/)", line 300, in insert

self.db_insert(ignore_if_duplicate=ignore_if_duplicate)

File "apps/frappe/frappe/model/base_[document.py](http://document.py/)", line 585, in db_insert

raise frappe.DuplicateEntryError(self.doctype, [self.name](http://self.name/), e)

frappe.exceptions.DuplicateEntryError: ('App', 'lending', IntegrityError(1062, "Duplicate entry 'lending' for key 'PRIMARY'"))

BreadGenie avatar Mar 22 '24 06:03 BreadGenie

I don't think we should allow users to add through public link image

Show only the "Your Github App" flow to them

BreadGenie avatar Mar 22 '24 06:03 BreadGenie