Skip to content

fix: small correctness/security cleanups in apps-python / python-sdk examples#535

Open
jamesbroadhead wants to merge 1 commit into
databricks-solutions:mainfrom
jamesbroadhead:ace-review-fixes-main
Open

fix: small correctness/security cleanups in apps-python / python-sdk examples#535
jamesbroadhead wants to merge 1 commit into
databricks-solutions:mainfrom
jamesbroadhead:ace-review-fixes-main

Conversation

@jamesbroadhead
Copy link
Copy Markdown

Summary

Subset of fixes surfaced by a parallel GPT 5.4 + Gemini 3.1 Pro code review, scoped to files that exist on main. (The companion experimental-branch PR contains a larger superset; mas_manager.py and compute.py live only under databricks-skills/ on experimental.)

databricks-app-python/examples/llm_config.py (security)

  • OAuth error no longer interpolates the full token-endpoint payload (which can contain id_token / refresh material). Logs the present key names instead.
  • DATABRICKS_MODEL validation error drops the response.text[:300] echo so server bodies don't end up in operator-visible error text.

databricks-app-python/examples/fm-minimal-chat.py

  • Docstring + app.yaml examples reference the actual filename (fm-minimal-chat.py), not 2-minimal-chat-app.py.

databricks-app-python/examples/fm-parallel-calls.py

  • Guard Speedup division on total_time > 0 to avoid ZeroDivisionError on fast paths.
  • Convert the trailing standalone triple-quoted string (dead code) to real # comments.

databricks-python-sdk/examples/5-serving-and-vector-search.py

  • Replace the [0.1, 0.2, 0.3, ...] literal-Ellipsis vector with a named placeholder + comment explaining it's a stand-in (the literal would fail server-side if copied).

Companion PR

Equivalent (larger) PR for experimental — adds fixes to mas_manager.py and compute.py which exist there: #534

Test plan

  • python3 -m py_compile on all four modified files
  • CI green

This pull request and its description were written by Isaac.

Subset of fixes from the experimental-branch batch that apply to files
present on main. (mas_manager.py and compute.py don't exist under
databricks-skills/ on main; those fixes ship only on the experimental
companion PR.)

databricks-app-python/examples/llm_config.py:
- OAuth error no longer interpolates the full token-endpoint payload
  (which can contain `id_token` / refresh material). Logs the present
  key names instead.
- DATABRICKS_MODEL validation error drops the `response.text[:300]`
  echo so server bodies don't end up in operator-visible error text.

databricks-app-python/examples/fm-minimal-chat.py:
- Docstring + `app.yaml` examples reference the actual filename
  (`fm-minimal-chat.py`), not `2-minimal-chat-app.py`.

databricks-app-python/examples/fm-parallel-calls.py:
- Guard `Speedup` division on `total_time > 0` to avoid
  ZeroDivisionError on fast paths.
- Convert the trailing standalone triple-quoted string (dead code) to
  real `#` comments.

databricks-python-sdk/examples/5-serving-and-vector-search.py:
- Replace the `[0.1, 0.2, 0.3, ...]` literal-Ellipsis vector with a
  named placeholder + comment explaining it's a stand-in.

This pull request was AI-assisted by Isaac.

Co-authored-by: Isaac
@jamesbroadhead
Copy link
Copy Markdown
Author

Hi @calreynolds — could you take a look at this when you have a moment? Subset of fixes for main. Companion PR for experimental (larger) is #534.

— this comment was written by Claude

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.

1 participant