Skip to content

docs: Expand sandbox allowed imports with window functions and utilities#1127

Draft
promptless[bot] wants to merge 7 commits intomainfrom
promptless/expand-sandbox-allowed-imports
Draft

docs: Expand sandbox allowed imports with window functions and utilities#1127
promptless[bot] wants to merge 7 commits intomainfrom
promptless/expand-sandbox-allowed-imports

Conversation

@promptless
Copy link
Copy Markdown
Contributor

@promptless promptless bot commented Apr 3, 2026

Open this suggestion in Promptless to view citations and reasoning process

Documents newly allowed imports in the plugin sandbox from canvas-plugins PR #1615. Adds the html module (escape, unescape), urllib.parse.unquote, Django model fields (FloatField, Func), window expression classes (Window, RowRange, ValueRange), and Django window functions (CumeDist, DenseRank, FirstValue, Lag, LastValue, Lead, NthValue, Ntile, PercentRank, Rank, RowNumber). Also documents the previously undocumented Coalesce and Trim functions.

Add newly allowed imports from canvas-plugins PR #1615:
- html module: escape, unescape
- urllib.parse: unquote
- django.db.models: FloatField, Func, RowRange, ValueRange, Window
- django.db.models.functions: window functions (CumeDist, DenseRank,
  FirstValue, Lag, LastValue, Lead, NthValue, Ntile, PercentRank,
  Rank, RowNumber) plus Coalesce and Trim
@@ -202,6 +213,22 @@ Django's database expressions for complex query operations and conditional logic
- `Value`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added django.db.models.functions section with window functions (CumeDist, DenseRank, FirstValue, Lag, LastValue, Lead, NthValue, Ntile, PercentRank, Rank, RowNumber) plus Coalesce and Trim based on the allow list additions in plugin_runner/sandbox.py.

Source: canvas-medical/canvas-plugins#1615

- `compare_digest`
- `new`

##### `html`
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added html module with escape and unescape functions based on ALLOWED_MODULE_ATTRIBUTES additions in plugin_runner/sandbox.py.

Source: canvas-medical/canvas-plugins#1615

@beaugunderson
Copy link
Copy Markdown
Member

@djantzen we're trialing promptless--let me know what you think of this result

@aws-amplify-us-west-2
Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-1127.d298pum72820gn.amplifyapp.com

@djantzen
Copy link
Copy Markdown
Contributor

djantzen commented Apr 4, 2026

@djantzen we're trialing promptless--let me know what you think of this result

@djantzen we're trialing promptless--let me know what you think of this result

@beaugunderson Fundamentally similar to what I did (with Claude) except for removing the requests section. What are the instructions to promptless? Does it just look at every canvas-plugins PR and try to document the changes?

promptless bot added 4 commits April 4, 2026 01:58
Adds the `time` class from the datetime module to the list of allowed
imports in the plugin sandbox, per canvas-plugins PR #1595.
Document that plugin developers can use requests.codes for HTTP status code
constants (like requests.codes.ok, requests.codes.not_found) in the sandbox.
Enabled by canvas-plugins PR #1597.
Adds nanosecond-precision time function to the allowed imports list.
Enabled by canvas-plugins PR #1598.
Documents additional sandbox items from canvas-plugins PR #1615:
- traceback.format_exc for exception formatting
- extract_exc_frames builtin for safe frame extraction
- __args__, __members__, __origin__, __traceback__ dunder attributes
@promptless
Copy link
Copy Markdown
Contributor Author

promptless bot commented Apr 4, 2026

I noticed that some CI checks failed for this PR. I'm investigating whether the failures are caused by this suggestion. If they're unrelated or pre-existing, I'll leave this suggestion unchanged and create a separate suggestion if a standalone docs fix is needed.

promptless bot added 2 commits April 4, 2026 05:18
- Add `from logger import log` to both code examples
- Change `logger.info` to `log.info` to match standard pattern
- Mark blocks as partial since they use Canvas sandbox builtins
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