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

Not possible to write custom plugins anymore #4406

Closed
1 of 2 tasks
macobo opened this issue May 19, 2021 · 5 comments
Closed
1 of 2 tasks

Not possible to write custom plugins anymore #4406

macobo opened this issue May 19, 2021 · 5 comments
Labels
bug Something isn't working right

Comments

@macobo
Copy link
Contributor

macobo commented May 19, 2021

Bug description

#4371 added a new capabilities column. After it it's not possible to start creating a new plugin anymore

Expected behavior

Should be possible to add a new plugin

How to reproduce

  1. Go to plugins > Advanced
  2. Add a name and click Start coding
  3. See an error
Internal Server Error: /api/organizations/@current/plugins/
Traceback (most recent call last):
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.NotNullViolation: null value in column "capabilities" violates not-null constraint
DETAIL:  Failing row contains (2, Testa, null, null, {}, null, null, f, f, null, source, , 01798451-3355-0000-34f0-3beee71dab27, null, null, 2021-05-19 19:55:34.00628+00, 2021-05-19 19:55:34.006387+00, f, f, null).


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

Traceback (most recent call last):
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/rest_framework/mixins.py", line 19, in create
    self.perform_create(serializer)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/rest_framework/mixins.py", line 24, in perform_create
    serializer.save()
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/rest_framework/serializers.py", line 205, in save
    self.instance = self.create(validated_data)
  File "/home/macobo/backups/2/projects/posthog/posthog/api/plugin.py", line 132, in create
    plugin = Plugin.objects.install(**validated_data)
  File "/home/macobo/backups/2/projects/posthog/posthog/models/plugin.py", line 105, in install
    return Plugin.objects.create(**kwargs)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/models/query.py", line 447, in create
    obj.save(force_insert=True, using=self.db)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/models/base.py", line 753, in save
    self.save_base(using=using, force_insert=force_insert,
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/models/base.py", line 790, in save_base
    updated = self._save_table(
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/models/base.py", line 895, in _save_table
    results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/models/base.py", line 933, in _do_insert
    return manager._insert(
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/models/query.py", line 1254, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1397, in execute_sql
    cursor.execute(sql, params)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/backends/utils.py", line 98, in execute
    return super().execute(sql, params)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/macobo/.pyenv/versions/posthog-core/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: null value in column "capabilities" violates not-null constraint
DETAIL:  Failing row contains (2, Testa, null, null, {}, null, null, f, f, null, source, , 01798451-3355-0000-34f0-3beee71dab27, null, null, 2021-05-19 19:55:34.00628+00, 2021-05-19 19:55:34.006387+00, f, f, null).

Environment

  • PostHog Cloud
  • self-hosted PostHog, version/commit: latest master

Additional context

cc @neilkakkar for this bug.

It's worth creating a cypress e2e test which goes through this flow.

Thank you for your bug report – we love squashing them!

@macobo macobo added the bug Something isn't working right label May 19, 2021
@macobo macobo changed the title Not possible to add any custom plugins anymore Not possible to write custom plugins anymore May 19, 2021
@mariusandra
Copy link
Collaborator

This could have been caught if we had any cypress tests for the plugins frontend. Not sure we wouldn't have just ignored the failing test then though. 😬

@Twixes
Copy link
Member

Twixes commented May 20, 2021

I'm pretty sure this was a wrong branch after running the capabilities migration. No such problem occurred for me locally, and I'm not experiencing this on Cloud (where this feature is enabled only for the PostHog org) either.

@neilkakkar
Copy link
Contributor

Same, waiting for Karl to confirm he can re-reproduce.

About Cypress tests for Plugins: sounds like a good idea to me, doing this with the default source plugin. I'll do this.

@mariusandra
Copy link
Collaborator

I've deprioritized cypress tests for now, since there's a big batch of plugin frontend work that will land on our plate in the near future, but probably not next sprint (stuff like improving the editor, making failures more interactive (no need to reload), changing the URL if you have a plugin open, testing environment, etc), and it might make sense to combine this work.

@macobo
Copy link
Contributor Author

macobo commented May 20, 2021

Verified, this seems to have been exactly the scenario @Twixes suggested. Sorry for the noise!

@macobo macobo closed this as completed May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working right
Projects
None yet
Development

No branches or pull requests

4 participants