Full review will take a while, but I do have one initial comment:
On Thu Jul 14, 2022 at 6:47 PM CEST, Adnan Maolood wrote:
> +def fetch_user_id(username):> + resp = exec_gql("meta.sr.ht",> + "query($username: String!) { user(username: $username) { id } }",> + user=internal_anon,> + username=username)> + return resp["user"]["id"]
We should make some attempt to gracefully deal with any errors that
could occur here.
Some issues:
celery_webhook_subscription and webhook_subscription don't exist
Also, I ran into an issue. I started with a fresh todo.sr.ht database
initialized with a schema dumped from production[0], logged in as user A
and created a tracker, added it to a hub project, and created a ticket.
Then I ran the migrations and everything works. However, when I logged
in as user B (who did not previously exist in the todo database), it
blew up:
sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "user_old_id_key"
DETAIL: Key (old_id)=(1) already exists.
[SQL:
INSERT INTO "user" (
created, updated, id, username, email, user_type, url, location,
bio, suspension_notice
) VALUES (
NOW() at time zone 'utc',
NOW() at time zone 'utc',
%(id)s, %(name)s, %(email)s, %(user_type)s, %(url)s, %(location)s, %(bio)s, %(suspension_notice)s
)
ON CONFLICT (id)
DO UPDATE SET
updated = NOW() at time zone 'utc',
username = %(name)s,
email = %(email)s,
user_type = %(user_type)s,
url = %(url)s,
location = %(location)s,
bio = %(bio)s,
suspension_notice = %(suspension_notice)s
RETURNING id, username, email, user_type, url, location, bio, suspension_notice;
]
[parameters: {'id': 5, 'name': 'jim', 'email': 'jim@cmpwn.com', 'user_type': 'active_non_paying', 'url': None, 'location': None, 'bio': None, 'suspension_notice': None}]
(Background on this error at: https://sqlalche.me/e/14/gkpj)
[0]: https://paste.sr.ht/~sircmpwn/34b767daed7c2cebf656c7fb71cbf2c841ba570b
I will have more work to do to review & validate these patches, but
let's start by addressing these issues before we move on.
On Thu Jul 28, 2022 at 6:57 AM EDT, Drew DeVault wrote:
> Some issues:>> celery_webhook_subscription and webhook_subscription don't exist
Odd. These tables are created by todosrht-initdb.
> Also, I ran into an issue. I started with a fresh todo.sr.ht database> initialized with a schema dumped from production[0], logged in as user A> and created a tracker, added it to a hub project, and created a ticket.> Then I ran the migrations and everything works. However, when I logged> in as user B (who did not previously exist in the todo database), it> blew up:>> sqlalchemy.exc.IntegrityError: (psycopg2.errors.UniqueViolation) duplicate key value violates unique constraint "user_old_id_key"> DETAIL: Key (old_id)=(1) already exists.>> [SQL: > INSERT INTO "user" (> created, updated, id, username, email, user_type, url, location,> bio, suspension_notice> ) VALUES (> NOW() at time zone 'utc',> NOW() at time zone 'utc',> %(id)s, %(name)s, %(email)s, %(user_type)s, %(url)s, %(location)s, %(bio)s, %(suspension_notice)s> )> ON CONFLICT (id)> DO UPDATE SET> updated = NOW() at time zone 'utc',> username = %(name)s,> email = %(email)s,> user_type = %(user_type)s,> url = %(url)s,> location = %(location)s,> bio = %(bio)s,> suspension_notice = %(suspension_notice)s> RETURNING id, username, email, user_type, url, location, bio, suspension_notice;> ]> [parameters: {'id': 5, 'name': 'jim', 'email': 'jim@cmpwn.com', 'user_type': 'active_non_paying', 'url': None, 'location': None, 'bio': None, 'suspension_notice': None}]> (Background on this error at: https://sqlalche.me/e/14/gkpj)
I can't reproduce this issue. Can you confirm that user_id_seq is set to
the last value of user.old_id?