Skip to content

feat: warn when bot starts without credentials#435

Merged
corinagum merged 1 commit into
mainfrom
cg/devtools-deprecation
May 26, 2026
Merged

feat: warn when bot starts without credentials#435
corinagum merged 1 commit into
mainfrom
cg/devtools-deprecation

Conversation

@corinagum

@corinagum corinagum commented May 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a startup warning in HttpServer.initialize() when no CLIENT_ID / CLIENT_SECRET / TENANT_ID is configured, so customers running anonymously know their bot accepts unauthenticated requests on /api/messages.
  • 2 new unit tests in test_http_server.py covering: warning fires when no creds, warning does not fire when creds present.

Why

Part of the DevTools deprecation rollout. The recommended local-testing path with Microsoft 365 Agents Playground is anonymous mode (no creds configured). The new warning makes that mode explicit at startup, so customers don't ship anonymous-mode bots to production by accident, and so the migration from DevTools to Playground produces a clear signal.

Behavior is unchanged. This is pure observability.

Test plan

  • pytest tests/test_http_server.py (22/22 passing)
  • Confirmed warning text matches the wording used in teams.ts and teams.net for cross-SDK consistency
  • Verified at runtime by initializing App() without credentials. Output:
    [WARNING] microsoft_teams.apps.http.http_server: No credentials configured (CLIENT_ID / CLIENT_SECRET / TENANT_ID). Bot will accept unauthenticated requests on /api/messages.
    
    Note: Uvicorn's dictConfig replaces the default root-logger handler at server-startup, so consumers running through Uvicorn need their own logging config (or logging.basicConfig(level=WARNING)) to see this warning. Customers using the standard Agents templates already have logging configured.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 22, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds a startup log warning to make “anonymous mode” explicit when the Teams bot HTTP server is initialized without credentials, improving observability and helping prevent accidental production deployments that accept unauthenticated traffic.

Changes:

  • Emit a WARNING from HttpServer.initialize() when no client_id is present on provided credentials (i.e., credentials are unset).
  • Add unit tests validating the warning is emitted when credentials are missing and not emitted when credentials are provided.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/apps/src/microsoft_teams/apps/http/http_server.py Adds a startup warning when initializing the messaging endpoint without credentials.
packages/apps/tests/test_http_server.py Adds unit tests covering warning/no-warning behavior during HttpServer.initialize().

Comment thread packages/apps/src/microsoft_teams/apps/http/http_server.py
@corinagum
corinagum force-pushed the cg/devtools-deprecation branch from 94398fa to 6bbc718 Compare May 22, 2026 20:57
@corinagum

corinagum commented May 22, 2026

Copy link
Copy Markdown
Contributor Author

On the Copilot suggestion to add a separate warning when skip_auth=True is set with valid credentials: this is intentional. Cross-SDK design decision (same in teams.ts and teams.net) to warn only on missing credentials, not on the explicit skip_auth opt-in.

Rationale:

  • skip_auth=True is an explicit user opt-in. Adding a warning would create noise for users who deliberately enable it (e.g., during local dev with Playground).
  • The anonymous-mode warning is the safety net for the un-flagged case (no credentials configured), which is the easier mistake to make.

Marking as won't-fix for cross-SDK consistency.

@corinagum
corinagum merged commit ad41dc2 into main May 26, 2026
7 checks passed
@corinagum
corinagum deleted the cg/devtools-deprecation branch May 26, 2026 19:15
corinagum added a commit that referenced this pull request May 27, 2026
## Summary

Brings `origin/main` into `release` for the **2.0.12** release. **No
carve-outs this time** — Quoted Replies (PR #321) is included.

`version.json`: `2.0.11` → `2.0.12`.

Aligns with teams.ts/teams.net cadence.

## What's in this release (delta from 2.0.11)

**Features**
- Quoted Replies & new quotes features (#321) — previously held back
- SuggestedActionSubmitActivity for `suggestedAction/submit` invoke
(#434)
- Default targeted replies for targeted inbound messages (#439)
- Reactions API marked GA (#427) — already shipped in 2.0.11 actually,
ignore if duplicate
- Prompt Preview support (#397)
- Sample: opt targeted-messages into slash commands (#430)
- Sample: a2a-in-teams (#401)
- Sample: proactive message update (#405)
- Allow custom HTTP client via `AppOptions` (#416)

**Security & fixes**
- Lock JsonWebToken trust-boundary contract (#432)
- Bump starlette 1.0.0 -> 1.1.0 for PYSEC-2026-161 / BadHost (#441)
- warn when bot starts without credentials (#435)
- fix(apps): support AAD v1 issuers in Entra token validation (#422)
- fix(apps): log inbound activities at info, warn on missing
Authorization (#425)
- fix(http-stream): wait for in-flight flush before sending final close
(#419)
- Mark reactions API as GA and fix sample remove flow (#427)
- Revert serviceUrl allowlist (ADO 5310460) (#415)
- Route `app.get_app_graph` + `ctx.*_graph` to sovereign endpoints via
`cloud.graph_scope` (#402)

**Deprecations / package changes**
- Remove ai, openai, mcpplugin, a2a, and devtools packages (#413)
- Restore and deprecate devtools package (#410)
- Deprecate ai, openai, mcpplugin, a2a packages (#406)
- Add agent framework example, remove chatprompt/mcp client samples
(#386)

**Dependency bumps**
- urllib3 2.6.3 → 2.7.0 (#426)
- python-multipart 0.0.26 → 0.0.27 (#424)
- microsoft-kiota-http 1.9.7 → 1.9.9 (#423)
- idna 3.11 → 3.15 (#431)
- starlette 1.0.0 → 1.1.0 (#441, security)
- /examples/tab/Web: qs, postcss, uuid, follow-redirects bumps

## Quoted Replies inclusion notes

- Teams client rendering is in-sync with the wire format as of
2026-05-06.
- APX QR rollout completed: Public 2026-04-10, GCCH/DoD/Gallatin
2026-04-14.
- Builder methods (`prepend_quote()`, `add_quote()`), `ctx.quote()`, and
the quote-aware `ctx.reply()` behavior are all present in this release.
- `examples/quoting` is included.

## Conflict resolution

The 2.0.11 release branch had the QR-removed shape for four files; took
`main`'s (QR-included) version for all of them:
- `examples/targeted-messages/src/main.py`
- `packages/api/src/microsoft_teams/api/activities/message/message.py`
- `packages/apps/src/microsoft_teams/apps/routing/activity_context.py`
- `packages/apps/tests/test_activity_context.py`

`version.json` conflict resolved to `2.0.12`.

## Test plan

- [x] `uv sync` clean
- [x] `poe check` (ruff format + lint) — clean
- [x] `poe test` — 609 passed
- [x] `pyright` — 0 errors, 0 warnings
- [ ] Pipeline build + test stages green on `release` after merge
- [ ] Publish pipeline run with **Public** → ESRP approval → PyPI
- [ ] `pip install microsoft-teams-apps==2.0.12` smoke install

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: Aamir Jawaid <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
Co-authored-by: Shanmathi Mayuram Krithivasan <[email protected]>
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.

3 participants