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

Convert user_id to str if UUID used as PK #45

Merged
merged 2 commits into from Oct 5, 2020
Merged

Convert user_id to str if UUID used as PK #45

merged 2 commits into from Oct 5, 2020

Conversation

fadedDexofan
Copy link
Contributor

Fix for py-ampq FrameSyntaxError during serialization in Celery

Fix for py-ampq FrameSyntaxError during serialization in Celery
Convert user_id to str if UUID used as PK
@codecov
Copy link

codecov bot commented Aug 26, 2020

Codecov Report

Merging #45 into master will decrease coverage by 0.09%.
The diff coverage is 75.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##            master      #45      +/-   ##
===========================================
- Coverage   100.00%   99.90%   -0.10%     
===========================================
  Files           40       40              
  Lines         1080     1083       +3     
===========================================
+ Hits          1080     1082       +2     
- Misses           0        1       +1     
Impacted Files Coverage Δ
django_structlog/middlewares/request.py 98.00% <75.00%> (-2.00%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 53c6a90...4b0d43a. Read the comment docs.

@jrobichaud
Copy link
Owner

I believe you could just use this signal to do this:

https://django-structlog.readthedocs.io/en/latest/api_documentation.html#django_structlog.celery.signals.modify_context_before_task_publish

>>> from django.dispatch import receiver
>>> from django_structlog.celery import signals
>>>
>>> @receiver(signals.modify_context_before_task_publish)
... def receiver_modify_context_before_task_publish(sender, signal, context):
...     if "user_id" in context and context["user_id"]:
...         context["user_id"] = str(context["user_id"])

@jrobichaud
Copy link
Owner

I created the issue #46 to find a more generic solution. Thank you @fadedDexofan for this proposition.

@jrobichaud jrobichaud closed this Aug 27, 2020
@jrobichaud
Copy link
Owner

@fadedDexofan could you show me how to reproduce the problem using the demo project?

@jrobichaud
Copy link
Owner

This PR finally fixes #51 I noticed while trying to reproduce your problem.

@jrobichaud jrobichaud reopened this Oct 5, 2020
@jrobichaud jrobichaud changed the base branch from master to uuid-as-user-pk October 5, 2020 00:23
@jrobichaud jrobichaud merged commit ee7ddb5 into jrobichaud:uuid-as-user-pk Oct 5, 2020
@jrobichaud
Copy link
Owner

@fadedDexofan in 1.6.2 there is your fix so you might want to upgrade and remove the workaround I gave you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants