Skip to content

Fix Ballerina Github connector publishing flow code - #135

Open
PasinduGunarathne wants to merge 2 commits into
wso2:mainfrom
PasinduGunarathne:pasindug-patch-2
Open

Fix Ballerina Github connector publishing flow code#135
PasinduGunarathne wants to merge 2 commits into
wso2:mainfrom
PasinduGunarathne:pasindug-patch-2

Conversation

@PasinduGunarathne

Copy link
Copy Markdown

Purpose

  • Fix issues in the sample code of the GitHub Ballerina connector publishing flow and update the integration samples

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

@coderabbitai

coderabbitai Bot commented May 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 90f28c9d-89ef-4a6d-ad9c-29d70ed6d20a

📥 Commits

Reviewing files that changed from the base of the PR and between 9d05a86 and acde45a.

📒 Files selected for processing (2)
  • integrator-default-profile/connectors/github_trigger_sample/automation.bal
  • integrator-default-profile/connectors/github_trigger_sample/config.bal
🚧 Files skipped from review as they are similar to previous changes (2)
  • integrator-default-profile/connectors/github_trigger_sample/config.bal
  • integrator-default-profile/connectors/github_trigger_sample/automation.bal

📝 Walkthrough

Overview

This PR fixes and updates the Ballerina GitHub connector publishing/sample code in the integration-samples repository. It adds a runnable GitHub trigger sample that demonstrates authenticating with GitHub and creating an issue via the Ballerina GitHub client.

Changes

Three files were added or updated under integrator-default-profile/connectors/github_trigger_sample/:

  • config.bal

    • Added a configurable githubAuthToken parameter (in addition to existing webhook and listener settings).
  • connections.bal

    • Imports the GitHub client library and initializes a module-level github:Client using the configured token.
  • automation.bal

    • Adds configurable owner and repo parameters.
    • Adds a public function main() returns error? entrypoint which creates a GitHub issue with a fixed title, logs the created issue number and URL, and returns/logs errors on failure.

Notes and gaps

  • The PR description contains many template sections (Goals, Approach, Tests, Documentation, Security checks, Related PRs, etc.) but these were left as placeholders with no concrete details, documentation links, test results, or related-PR references included.
  • No automation tests or additional documentation are included in this change set.

Walkthrough

This pull request adds a GitHub trigger sample connector. It declares configurable parameters for githubAuthToken, owner, and repo; initializes an authenticated github:Client using the token; and implements a public main() that posts an issue to /repos/{owner}/{repo}/issues, logging the created issue’s number and URL or returning/logging any error.

Sequence Diagram(s)

sequenceDiagram
  participant Main
  participant GitHubClient as github:Client
  participant GitHubAPI as GitHub API
  participant Logger

  Main->>GitHubClient: POST /repos/{owner}/{repo}/issues (create issue)
  GitHubClient->>GitHubAPI: HTTP POST issue payload (auth: githubAuthToken)
  GitHubAPI-->>GitHubClient: 201 Created (issue number, URL)
  GitHubClient->>Logger: log issue number and URL
  GitHubClient-->>Main: return success
  Note right of GitHubClient: on error -> log error and return error to Main
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only fills in the Purpose section with minimal detail; the majority of required template sections remain unfilled placeholders without concrete information. Complete the Goals, Approach, and other key sections with specific details about the fixes and testing performed. Provide concrete answers to security check questions rather than leaving them as prompts.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly relates to the changeset, which adds code to fix the GitHub Ballerina connector sample implementation.
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 unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2

🧹 Nitpick comments (2)
integrator-default-profile/connectors/github_trigger_sample/connections.bal (2)

5-5: ⚡ Quick win

Remove redundant string interpolation.

The githubAuthToken variable is already of type string, so the string interpolation is unnecessary.

♻️ Proposed fix
-        token: string `${githubAuthToken}`
+        token: githubAuthToken
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@integrator-default-profile/connectors/github_trigger_sample/connections.bal`
at line 5, The token field uses unnecessary string interpolation; replace the
expression token: string `${githubAuthToken}` with a direct reference token:
githubAuthToken (removing the backtick/template syntax) so the string value from
githubAuthToken is used directly and the redundant interpolation is eliminated.

1-7: Use the documented github:ConnectionConfig pattern for client initialization.

The library documentation shows explicitly creating a github:ConnectionConfig before initializing the client. Update to:

import ballerinax/github;

final github:ConnectionConfig config = {
    auth: {
        token: string `${githubAuthToken}`
    }
};
final github:Client githubClient = check new (config);

This aligns with the ballerinax/github library's recommended initialization pattern.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@integrator-default-profile/connectors/github_trigger_sample/connections.bal`
around lines 1 - 7, Replace the direct Client construction with the documented
ConnectionConfig pattern: create a github:ConnectionConfig object (e.g., config)
that sets auth.token using the existing githubAuthToken value, then pass that
config into the github:Client constructor; update references to githubClient to
use the new initialization via check new (config) and ensure the import and
token interpolation remain unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@integrator-default-profile/connectors/github_trigger_sample/automation.bal`:
- Around line 9-11: The current call uses resource path syntax to post an issue;
replace it with the library's createIssue remote function: construct a
github:CreateIssueInput record with the title, then call
githubClient->createIssue(inputPayload, owner, repo) and assign the result to
github:Issue githubIssue (handling the check as before). Update the code that
references githubClient, githubIssue, CreateIssueInput, owner and repo
accordingly.

In `@integrator-default-profile/connectors/github_trigger_sample/connections.bal`:
- Around line 3-7: The module-level use of check when creating githubClient
(final github:Client githubClient = check new ...) will cause a panic if
initialization fails; change to safe initialization by removing the module-level
check and either (a) initialize githubClient lazily inside a function (e.g.,
getGithubClient or initGithubClient) that returns an optional or error and uses
trap/if (error) handling, or (b) wrap the new github:Client creation with
trap/var and log or propagate the error instead of panicking, using the
githubAuthToken value for the token; ensure callers handle a nil/optional
githubClient or the returned error accordingly.

---

Nitpick comments:
In `@integrator-default-profile/connectors/github_trigger_sample/connections.bal`:
- Line 5: The token field uses unnecessary string interpolation; replace the
expression token: string `${githubAuthToken}` with a direct reference token:
githubAuthToken (removing the backtick/template syntax) so the string value from
githubAuthToken is used directly and the redundant interpolation is eliminated.
- Around line 1-7: Replace the direct Client construction with the documented
ConnectionConfig pattern: create a github:ConnectionConfig object (e.g., config)
that sets auth.token using the existing githubAuthToken value, then pass that
config into the github:Client constructor; update references to githubClient to
use the new initialization via check new (config) and ensure the import and
token interpolation remain unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f3232e88-cd85-45f8-9a41-c9bf27da9a53

📥 Commits

Reviewing files that changed from the base of the PR and between b137471 and 9d05a86.

📒 Files selected for processing (3)
  • integrator-default-profile/connectors/github_trigger_sample/automation.bal
  • integrator-default-profile/connectors/github_trigger_sample/config.bal
  • integrator-default-profile/connectors/github_trigger_sample/connections.bal

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