Skip to content

feat: add hello world example and rework http client sample - #122

Merged
warunalakshitha merged 6 commits into
mainfrom
http-client-sample
Aug 13, 2026
Merged

warunalakshitha merged 6 commits into
mainfrom
http-client-sample

Conversation

@TharmiganK

@TharmiganK TharmiganK commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Replace the HTTP client sample's httpbun-based subscriber sync with a Ballerina Central package search example, harden the e2e fixture-matching helper for output that legitimately varies between runs (package rankings, pull counts, timestamps), and add a minimal "Hello, World!" example as the first, default-opened example.

Changes

  • HTTP client sample: now queries the Ballerina Central registry for packages matching a keyword and prints the most-pulled matches, sorted by pull count. Fetches a larger page in a single request instead of relying on the registry's default page size, and the "Top N" header reflects the actual number of qualifying packages instead of a hardcoded 5.
  • E2E fixtures: <package>, <number>, and <timestamp> placeholders let a fixture match live/volatile output while everything else around them still matches exactly. Regenerating a fixture (UPDATE_EXAMPLE_OUTPUTS=1) now refuses to silently overwrite one that relies on <package>/<number> placeholders when it no longer matches, since those values can't be canonicalized back out of raw output.
  • New hello-world example: added as 01-hello-world and set as the playground's default file; the client and service examples are renumbered to 02 and 03.

Summary by CodeRabbit

  • Examples
    • Added a Hello World example.
    • Added an HTTP client example that searches the Ballerina package registry for AWS-related packages and displays the five most popular results.
    • Added an HTTP service example for listing, creating, and retrieving albums.
    • Replaced the previous customer and subscriber synchronization example.
  • Tests
    • Improved example output validation with package, number, and timestamp placeholders.
    • Added coverage for the new example outputs.

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 77b63591-03ad-47c5-8efa-563f8c3da30b

📥 Commits

Reviewing files that changed from the base of the PR and between 3a36129 and 854632c.

📒 Files selected for processing (1)
  • apps/web/src/components/file-route-sync.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/src/components/file-route-sync.tsx

📝 Walkthrough

Walkthrough

The PR reorganizes the examples into numbered hello-world, HTTP client, and HTTP service projects. It adds package metadata and fixtures, updates example paths, removes the former HTTP client, and expands E2E output validation with number, package, and timestamp placeholders.

Changes

Numbered example projects

Layer / File(s) Summary
Hello-world example and default route
examples/01-hello-world/*, e2e/fixtures/examples/01-hello-world.txt, apps/web/src/components/file-route-sync.tsx
Adds the hello-world package, fixture output, and new default file route.
Package registry query
examples/02-http-client/*, e2e/fixtures/examples/02-http-client.txt
Adds a typed HTTP client that retrieves, filters, sorts, limits, and prints popular AWS packages.
Album service and E2E path
examples/03-http-service/*, e2e/fixtures/examples/03-http-service.txt, e2e/tests/examples.spec.ts
Adds the album service, its output fixture, and the updated service manifest path.
Placeholder-aware output validation
e2e/helpers/example-output.ts
Adds anchored matching for <number>, <package>, and <timestamp> placeholders. Fixture updates preserve compatible placeholders and reject incompatible regeneration.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Example as HTTP client example
  participant Registry as Ballerina package registry
  participant Validator as E2E output validator
  Example->>Registry: Request AWS package data
  Registry-->>Example: Return package search JSON
  Example->>Example: Filter and rank packages
  Example-->>Validator: Print package results
  Validator->>Validator: Match placeholder-aware fixture pattern
Loading

Possibly related PRs

Suggested reviewers: warunalakshitha

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description explains the purpose and main changes, but it omits most required template sections, including testing, security, documentation, release notes, and environment details. Complete the required template sections, including Goals, Approach, User stories, Release note, Documentation, tests, security checks, Samples, and Test environment.
✅ Passed checks (3 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main changes: adding a Hello World example and reworking the HTTP client sample.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch http-client-sample

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.

@snelusha snelusha 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.

LGTM

@snelusha

Copy link
Copy Markdown
Contributor

@TharmiganK Could you also update the example output fixtures by running:

bun run test:e2e:update-examples

@snelusha

Copy link
Copy Markdown
Contributor

@TharmiganK Since the packages and pull counts are dynamic, we cannot maintain a fixed output fixture for this example, right? I had to normalize the Ballerina logs for the HTTP service example as well.

function normalizeExampleOutput(output: string) {
return output.trimEnd().replace(/^time=\S+/gm, "time=<timestamp>");
}

@TharmiganK

Copy link
Copy Markdown
Contributor Author

@TharmiganK Since the packages and pull counts are dynamic, we cannot maintain a fixed output fixture for this example, right? I had to normalize the Ballerina logs for the HTTP service example as well.

function normalizeExampleOutput(output: string) {
return output.trimEnd().replace(/^time=\S+/gm, "time=<timestamp>");
}

Yes, will follow this for the client test as well

@TharmiganK
TharmiganK requested a review from snelusha August 11, 2026 10:59

@snelusha snelusha 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.

LGTM, just a small nitpick.

Comment thread e2e/helpers/example-output.ts Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
e2e/fixtures/examples/01-http-client.txt (1)

1-6: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Add semantic assertions for the dynamic rows.

The placeholders validate only output shape. <number> accepts 0, and <package> accepts any package. A regression can remove the pulls > 100 filter, change descending order, or emit duplicate rows without failing this fixture. Keep the placeholders, but add assertions for five unique rows with pull counts greater than 100 in non-increasing order.

🤖 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 `@e2e/fixtures/examples/01-http-client.txt` around lines 1 - 6, Strengthen the
assertions in the “Top 5 popular packages” fixture while retaining the existing
<package> and <number> placeholders: require five distinct package rows, each
with pulls greater than 100, and validate that pull counts are in non-increasing
order.
e2e/helpers/example-output.ts (1)

62-64: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Treat only missing fixtures as absent.

The catch-all handler hides permission, path, and I/O errors from readFile. Catch ENOENT only and rethrow other errors so fixture failures remain visible.

🤖 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 `@e2e/helpers/example-output.ts` around lines 62 - 64, Update the
loadExampleOutput call in the existingOutput initialization to catch only errors
with code ENOENT and return null for those missing fixtures. Rethrow all other
errors, including permission, path, and I/O failures, so loadExampleOutput
failures remain visible.
🤖 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 `@e2e/helpers/example-output.ts`:
- Around line 58-71: Update the example-output update flow after the
existingOutput pattern check to canonicalize volatile time= values before
writing the fixture. Ensure the fallback handled by the surrounding
output-generation function passes the normalized output to writeFile while
preserving all stable text unchanged.

---

Nitpick comments:
In `@e2e/fixtures/examples/01-http-client.txt`:
- Around line 1-6: Strengthen the assertions in the “Top 5 popular packages”
fixture while retaining the existing <package> and <number> placeholders:
require five distinct package rows, each with pulls greater than 100, and
validate that pull counts are in non-increasing order.

In `@e2e/helpers/example-output.ts`:
- Around line 62-64: Update the loadExampleOutput call in the existingOutput
initialization to catch only errors with code ENOENT and return null for those
missing fixtures. Rethrow all other errors, including permission, path, and I/O
failures, so loadExampleOutput failures remain visible.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 31aec7c2-be89-4bfe-b84e-0bb8ee719220

📥 Commits

Reviewing files that changed from the base of the PR and between 4be7703 and 3b36a39.

📒 Files selected for processing (3)
  • e2e/fixtures/examples/01-http-client.txt
  • e2e/helpers/example-output.ts
  • examples/01-http-client/main.bal
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/01-http-client/main.bal

Comment thread e2e/helpers/example-output.ts

@TharmiganK TharmiganK left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Claude PR Review Findings

Comment thread e2e/helpers/example-output.ts
Comment thread examples/02-http-client/main.bal
Comment thread examples/01-http-client/main.bal Outdated
Comment thread examples/01-http-client/main.bal Outdated
Comment thread examples/02-http-client/main.bal
Comment thread examples/02-http-client/main.bal
The HTTP client example now queries Ballerina Central, whose package
ranking, versions and pull counts all change upstream, so an exact
snapshot cannot hold. Support <package> and <number> placeholders in
example fixtures and use them for the HTTP client example.

Placeholders are scoped to the fixtures that need them so every other
example keeps exact-match assertions, and the fixture update mode leaves
a fixture alone while its placeholders still cover the output.
Timestamps varied for the same reason packages and pull counts do, so
drop the separate regex-based normalization step and add a <timestamp>
placeholder to the same mechanism, matching how fixtures already handle
live-service output.
Regenerating a fixture wrote the pane's raw time= value straight to disk,
so the very next normal run failed since that literal timestamp never
recurs. Canonicalize back to the <timestamp> placeholder only at the
write site, leaving the match-against-existing-fixture check untouched.
The registry API paginates at 15 packages per request by default, so
the top-5-by-pulls ranking was computed over a possibly incomplete
result set for broader queries. Request a larger limit in the single
call instead. The header also always said "Top 5" regardless of how
many packages actually cleared the pull-count threshold; print the
real count instead.

Also refuse to silently regenerate a fixture that relies on
<package>/<number> placeholders when it no longer matches — those
values can't be canonicalized back out of raw output, so overwriting
would re-bake today's literals and break again on the next run.
Renumber http-client to 02 and http-service to 03 to make room for a
minimal hello-world example as 01, and point the playground's default
opened file at it so it's what loads first.
@TharmiganK TharmiganK changed the title refactor: update http client sample feat: add hello world example and rework http client sample Aug 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 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 `@e2e/fixtures/examples/02-http-client.txt`:
- Around line 1-6: Update the popular-packages fixture so it accepts any number
of matching package rows up to five rather than requiring exactly five rows.
Preserve the existing query and pull-count output format while making the row
section variable-length, or replace it with deterministic data that guarantees
five matches.
🪄 Autofix

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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 24840596-c3da-403f-82f8-0f5e57cb6ebd

📥 Commits

Reviewing files that changed from the base of the PR and between 2f29562 and 3a36129.

📒 Files selected for processing (14)
  • apps/web/src/components/file-route-sync.tsx
  • e2e/fixtures/examples/01-hello-world.txt
  • e2e/fixtures/examples/01-http-client.txt
  • e2e/fixtures/examples/02-http-client.txt
  • e2e/fixtures/examples/03-http-service.txt
  • e2e/helpers/example-output.ts
  • e2e/tests/examples.spec.ts
  • examples/01-hello-world/Ballerina.toml
  • examples/01-hello-world/main.bal
  • examples/01-http-client/main.bal
  • examples/02-http-client/Ballerina.toml
  • examples/02-http-client/main.bal
  • examples/03-http-service/Ballerina.toml
  • examples/03-http-service/main.bal
💤 Files with no reviewable changes (2)
  • e2e/fixtures/examples/01-http-client.txt
  • examples/01-http-client/main.bal

Comment thread e2e/fixtures/examples/02-http-client.txt

@warunalakshitha warunalakshitha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@warunalakshitha
warunalakshitha merged commit 9f13cbd into main Aug 13, 2026
3 checks passed
@TharmiganK
TharmiganK deleted the http-client-sample branch August 14, 2026 04:32
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