Skip to content

fix(talk_bot): remove the dead appconfig_ex bot-secret fallback#435

Open
oleksandr-nc wants to merge 1 commit into
mainfrom
fix/talk-bot-drop-dead-appconfig-fallback
Open

fix(talk_bot): remove the dead appconfig_ex bot-secret fallback#435
oleksandr-nc wants to merge 1 commit into
mainfrom
fix/talk-bot-drop-dead-appconfig-fallback

Conversation

@oleksandr-nc
Copy link
Copy Markdown
Contributor

@oleksandr-nc oleksandr-nc commented May 29, 2026

⚠️ This pull request was generated by an AI coding agent and opened automatically. It was not manually authored or human-reviewed before opening — please review carefully before merging.

get_bot_secret() / aget_bot_secret() resolve a Talk bot's secret in two steps: first from the environment variable os.environ[sha1(APP_ID + "_" + callback_url)], and — if that is missing — by reading it from server-side app config via NextcloudApp().appconfig_ex.get_value(secret_key).

That second step is dead code. AppAPI's TalkBot rework (nextcloud/app_api#866) moved bot secrets into a dedicated ex_apps_talk_bots table and removed them from appconfig_ex, so a bot-secret lookup against the config store can never find anything — it always returns None.

It is also unnecessary, not merely dead. register_talk_bot() returns the secret on every call (AppAPI returns the existing secret for an already-registered bot, not only when minting a new one), and nc_py_api caches it into os.environ[bot_id] right after registering. ExApps re-register their bots on enable/startup, so the environment variable is always (re)populated — and that is what actually serves the secret in get_bot_secret(). The existing reset_bot_secret test flow confirms this: it pops the env var, then enabled_handler(True) re-registers and repopulates it.

This removes the fallback from both functions. It is behavior-preserving (the fallback returns None today regardless), removes a pointless OCS round-trip on the rare env-miss path, and drops the last stale appconfig_ex reference in the Talk path.

Surfaced while reviewing the AppAPI config-storage migration (appconfig_ex / preferences_exIAppConfig / IUserConfig); this is the nc_py_api-side follow-up to nextcloud/app_api#866.

Summary by CodeRabbit

  • Refactor
    • Bot secret retrieval now exclusively uses environment variables, removing the previous server-side fallback mechanism.

Review Change Stack

Signed-off-by: Oleksander Piskun <oleksandr2088@icloud.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 46d4750b-8fe4-4795-a676-9f42732736cc

📥 Commits

Reviewing files that changed from the base of the PR and between 36b42d8 and 8a88f2d.

📒 Files selected for processing (1)
  • nc_py_api/talk_bot.py

📝 Walkthrough

Walkthrough

Sync and async bot secret retrieval functions in talk_bot.py are simplified to source secrets exclusively from environment variables, removing prior server-side app configuration fallback paths. Function signatures and return types remain unchanged.

Changes

Bot secret environment-only lookup

Layer / File(s) Summary
Bot secret sync and async environment retrieval
nc_py_api/talk_bot.py
get_bot_secret() and aget_bot_secret() now retrieve secrets only from os.environ using the derived key, with server-side app configuration fallback removed from both functions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Title accurately describes the main change: removing a dead fallback code path from bot secret retrieval functions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/talk-bot-drop-dead-appconfig-fallback

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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