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

POWERSYNC prototype: add migration to create postgresql publication #1747

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

Dieterbe
Copy link
Contributor

@Dieterbe Dieterbe commented Aug 2, 2024

No description provided.

This is needed since the move to vite on the react side
This wasn't working well with when used over the API
This still needs to be clean up (specially the key generation, at the moment we
use a new dependency, but all this can be also done with the library we currently
use)
try:
return JsonResponse({'token': token, 'powersync_url': settings.POWERSYNC_URL}, status=200)
except Exception as e:
return JsonResponse({'error': str(e)}, status=500)

Check warning

Code scanning / CodeQL

Information exposure through an exception Medium

Stack trace information
flows to this location and may be exposed to an external user.

Copilot Autofix AI 9 days ago

To fix the problem, we need to ensure that detailed exception messages are not exposed to the end user. Instead, we should log the detailed error message on the server and return a generic error message to the client. This can be achieved by modifying the exception handling in the get_powersync_token function.

  1. Import the logging module if not already imported.
  2. Replace the line that returns the detailed error message with a line that logs the error and returns a generic error message.
Suggested changeset 1
wger/core/api/views.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/wger/core/api/views.py b/wger/core/api/views.py
--- a/wger/core/api/views.py
+++ b/wger/core/api/views.py
@@ -457,3 +457,4 @@
     except Exception as e:
-        return JsonResponse({'error': str(e)}, status=500)
+        logging.error(f'Error in get_powersync_token: {str(e)}')
+        return JsonResponse({'error': 'An internal error has occurred.'}, status=500)
 
EOF
@@ -457,3 +457,4 @@
except Exception as e:
return JsonResponse({'error': str(e)}, status=500)
logging.error(f'Error in get_powersync_token: {str(e)}')
return JsonResponse({'error': 'An internal error has occurred.'}, status=500)

Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
rolandgeider and others added 12 commits September 8, 2024 21:04
most convenient and should be just fine
This is only needed because powersync can't handle joins
- move create publication to core
- use ivm entries for the nutrition publications
# Conflicts:
#	wger/core/static/react/main.js
This is needed in the flutter app to properly be able to set IDs on device, since
the regular IDs can only be set by postgres.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants