villebro opened a new pull request, #37300:
URL: https://github.com/apache/superset/pull/37300

   ### SUMMARY
   Currently when backend extensions raise exceptions, they don't contain a 
reference to the actual file:
   
   ```python
   Traceback (most recent call last):
     File "/Users/ville/projects/superset/superset/tasks/executor.py", line 
108, in execute_task
       executor_fn(*args, **kwargs)
     File "<string>", line 36, in my_task
   ZeroDivisionError: division by zero
   ```
   
   This makes it difficult to track down where the error actually occurred.
   
   In this PR, we propose stack traces will have a reference to the source file 
as follows:
   - For bundled `supx` extensions, the reference will be 
`supx://<extension-id>/file.py`
   - For local development extensions. the reference will be the pull path to 
the dist file: `.../dist/.../file.py`
   
   This will make stack traces more actionable, both when developing locally, 
and also when using bundled supx files.
   
   **Local extension after changes:**
   
   ```python
   Traceback (most recent call last):
     File "/Users/ville/projects/superset/superset/tasks/executor.py", line 
108, in execute_task
       executor_fn(*args, **kwargs)
     File 
"/Users/ville/projects/superset-extensions/helloworld/dist/backend/src/helloworld/api.py",
 line 36, in my_task
       x = 120/0
   ZeroDivisionError: division by zero
   ```
   
   Notice that for local extensions, it's now showing the actual code that 
raised the error to help narrow down the problematic code.
   
   **supx bundle after changes:**
   
   ```python
   Traceback (most recent call last):
     File "/Users/ville/projects/superset/superset/tasks/executor.py", line 
108, in execute_task
       executor_fn(*args, **kwargs)
     File "supx://helloworld/backend/src/helloworld/api.py", line 36, in my_task
   ZeroDivisionError: division by zero
   ```
   
   Here we're intentionally **not** showing the code, as we don't want to 
expose more of the internals than necessary (line number and method should be 
fine). We can add parity with local extensions for supx bundles, but IMO it's 
an unnecessary leak of extension internals, so I advise against it. It would 
also consume slightly more memory, as we'd have to load the supx code into 
[linecache](https://docs.python.org/3/library/linecache.html). While the memory 
overhead is arguably negligible, it's still IMO unnecessary.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to