Skip to content

fix(config): align channel config types with built-in registry#1289

Merged
zhijianma merged 3 commits intoagentscope-ai:mainfrom
JasonBuildAI:fix-config-channel-union
Mar 12, 2026
Merged

fix(config): align channel config types with built-in registry#1289
zhijianma merged 3 commits intoagentscope-ai:mainfrom
JasonBuildAI:fix-config-channel-union

Conversation

@JasonBuildAI
Copy link
Contributor

@JasonBuildAI JasonBuildAI commented Mar 11, 2026

Summary

Align channel configuration types and API handling with the built-in channel registry.

Changes

  • config/config.py: Add MatrixConfig to ChannelConfigUnion so that the /config/channels/{channel_name} API and the generated OpenAPI schema correctly include the matrix built-in channel.
  • app/routers/config.py: Extend PUT /config/channels/{channel_name} to construct typed configs for mattermost, mqtt, and matrix channels using their respective Pydantic models, consistent with existing handling for other built-in channels.

Rationale

The built-in channel registry (src/copaw/app/channels/registry.py) already declares mattermost, mqtt, and matrix as built-in channels, and ChannelConfig includes a matrix: MatrixConfig field. However:

  • ChannelConfigUnion omitted MatrixConfig, leading to an incomplete OpenAPI schema
  • The config router only special-cased part of the built-in channels, causing inconsistent type handling

This PR makes the config schema and API behavior consistent across all built-in channels.

Testing

  • Local lint checks passed (flake8, mypy, pylint)
  • pre-commit run --all-files (pending full dev environment setup due to llama-cpp-python build requirements)
  • pytest (pending full dev environment setup)

Note: The changes are minimal and follow existing patterns exactly. The MatrixConfig omission is a clear bug, and the added branches in put_channel mirror the existing implementation for telegram, dingtalk, etc. No functional behavior changes are expected.

Backwards Compatibility

Fully backwards compatible:

  • No API endpoint changes
  • No request/response schema changes (only additions to Union types)
  • No behavior changes for existing channels
  • New type handling only affects Pydantic validation, not runtime logic

Type of Change

  • fix: bug fix / inconsistency fix
  • feat: new feature
  • docs: documentation only
  • refactor: code restructuring

@github-actions github-actions bot added the first-time-contributor PR created by a first time contributor label Mar 11, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses inconsistencies in the channel configuration system by aligning channel configuration types and API handling with the built-in channel registry. It ensures that the OpenAPI schema is complete and that the configuration API correctly processes typed configurations for all built-in channels, improving overall system consistency and robustness.

Highlights

  • OpenAPI Schema Alignment: MatrixConfig was added to ChannelConfigUnion to ensure the /config/channels/{channel_name} API and its OpenAPI schema correctly include the matrix built-in channel.
  • API Type Handling Consistency: The PUT /config/channels/{channel_name} endpoint was extended to construct typed configurations for mattermost, mqtt, and matrix channels using their respective Pydantic models, aligning with existing handling for other built-in channels.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/copaw/app/routers/config.py
    • Added conditional logic to put_channel to import and instantiate MattermostConfig, MQTTConfig, and MatrixConfig based on the channel_name.
  • src/copaw/config/config.py
    • Included MatrixConfig in the ChannelConfigUnion list.
Activity
  • Local lint checks (flake8, mypy, pylint) have passed.
  • pre-commit run --all-files and pytest are pending full development environment setup.
  • The author noted that changes are minimal, follow existing patterns, and no functional behavior changes are expected.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request aligns channel configuration types with the built-in registry by adding MatrixConfig to ChannelConfigUnion and handling mattermost, mqtt, and matrix channels in the configuration API. However, it introduces significant security risks as the configuration API endpoints lack authentication, allowing unauthorized modification of sensitive settings. Specifically, adding MatrixConfig to the public configuration union exposes sensitive access tokens in plain text. Additionally, the current implementation of channel handling logic in put_channel could be refactored to improve maintainability and reduce code repetition.

@JasonBuildAI JasonBuildAI temporarily deployed to maintainer-approved March 11, 2026 15:11 — with GitHub Actions Inactive
@zhijianma
Copy link
Member

@JasonBuildAI
Plz run pre-commit run --all-files and commit again.

Made-with: Cursor
Made-with: Cursor
@JasonBuildAI JasonBuildAI temporarily deployed to maintainer-approved March 11, 2026 15:50 — with GitHub Actions Inactive
@JasonBuildAI
Copy link
Contributor Author

@JasonBuildAI Plz run pre-commit run --all-files and commit again.

Thanks for the reminder. I’ve run pre-commit run --all-files locally and pushed an updated commit. I also refactored put_channel to use a mapping to satisfy the pylint check and keep the logic consistent for built-in channels.

Sorry for the extra iteration, and thanks for the review!

@zhijianma zhijianma merged commit 630189e into agentscope-ai:main Mar 12, 2026
19 checks passed
@github-actions
Copy link

Welcome to CoPaw! 🎉

Thank you @JasonBuildAI for your first contribution! Your PR has been merged. 🚀

We'd love to give you a shout-out in our release notes! If you're comfortable sharing, please reply to this comment with your social media handles using the format below:

discord: your_discord_handle
x: your_x_handle
xiaohongshu: your_xiaohongshu_id

Note: Only share what you're comfortable with — all fields are optional.

Thanks again for helping make CoPaw better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

first-time-contributor PR created by a first time contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants