larksuite / larksuite/oapi-sdk-python

Official callback guide contains non-runnable Python examples

Open Beginner friendly
#162 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
559
Forks
102
PR merge metrics
No merged PRs in 30d

Description

Page and affected package

Problem

Two current code examples on the official Python SDK callback page are not runnable as shown.

1. Persistent-connection example has a comment after a line continuation

The page shows this structure:

event_handler = lark.EventDispatcherHandler.builder("", "") \
    # Register callback handling functions with register_p2 as the prefix.
    .register_p2_card_action_trigger(do_card_action_trigger) \
    .register_p2_url_preview_get(do_url_preview_get) \
    .build()

A backslash cannot be followed by a comment line before the continued expression. Compiling the displayed code raises a SyntaxError at .register_p2_card_action_trigger(...).

2. Webhook example imports from a nonexistent top-level package

The Flask example uses:

from event.callback.model.p2_card_action_trigger import ...
from event.callback.model.p2_url_preview_get import ...

With lark-oapi 1.7.3 installed, those imports raise:

ModuleNotFoundError: No module named 'event'

The corresponding package paths are under lark_oapi.event.callback.model, and the persistent-connection example on the same page already uses that prefix.

Expected behavior

Every official quick-copy callback example should at least parse and import against the supported package version.

Suggested corrections

  • Move the explanatory comment before the builder expression, or use parentheses instead of backslash continuation.
  • Change both webhook imports to lark_oapi.event.callback.model....

I reloaded the deployed page and checked the current rendered examples rather than relying on cached text. I also searched open and closed issues, all pull request states, and repository history for the exact import and continuation symptoms. Issues #90, #112, and #126 concern callback payload/runtime behavior and do not cover these documentation errors.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the official callback guide at the linked Feishu page and compare its persistent-connection and webhook examples with lark-oapi 1.7.3. Check the corrected snippets by compiling the persistent-connection example and importing the webhook models against the supported package. Done means both quick-copy examples parse and import without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
82/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.