-
Notifications
You must be signed in to change notification settings - Fork 10
feat: Add Go hello-world example for APort /verify endpoint integration #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
uchibeke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start
- Please make this work for /verify and /verify/policy/[pack_id]
Review https://github.com/aporthq/aport-sdks/blob/main/middleware/express/src/index.ts
Also see http://localhost:8787/api/swagger-ui#/Verification/verifyPolicyDecision
And https://github.com/aporthq/aport-policies/tree/main/payments.charge.v1 for fields required for policies. Its different depending on the policy
|
okay will work on it |
Overall AssessmentGood effort creating a Go hello world example! However, there are critical misunderstandings about what the APort API does and which endpoint should be used for a "hello world" example. 🚨 Critical Issue: Wrong API EndpointProblem: Using Policy Verification Instead of Agent VerificationThe issue #27 asks for "a basic call to the APort Current Implementation: Uses url := fmt.Sprintf("%s/api/verify/policy/%s", baseURL, policy)Expected Implementation: Should use url := fmt.Sprintf("%s/api/verify/%s", baseURL, agentID)What's the Difference?1.
2.
Why This MattersFor a "Hello World" example:
The current implementation is actually a production verification example, not a hello world. 🔧 Required Changes1. Update
|
| Criteria | Status | Notes |
|---|---|---|
Single main.go file |
✅ Met | File exists |
In /examples/hello-world/go |
✅ Met | Correct location |
| Uses standard library | ✅ Met | Only net/http, encoding/json |
| Prints response data | Prints data but from wrong endpoint | |
| Simple README.md | Too complex for hello world | |
| Working example | ❌ Not met | Wrong endpoint (policy vs agent) |
| Proper documentation | ❌ Not met | Explains wrong concept |
| Go best practices | ✅ Met | Code is well-structured |
🎯 Conceptual Issues to Address
1. Misunderstanding of "Hello World"
A hello world example should be:
- Minimal: Fewest concepts possible
- No auth: Should work immediately without setup
- Read-only: View data, don't make decisions
- Educational: Introduce one concept at a time
Current implementation is actually an intermediate example that shows policy authorization.
2. Endpoint Confusion
There are several APort endpoints:
| Endpoint | Method | Auth | Purpose | Use in |
|---|---|---|---|---|
/api/verify/{agent_id} |
GET | No | View agent passport | Hello World ✅ |
/api/verify/policy/{policy} |
POST | Yes | Check authorization | Production ❌ |
/api/passports/{agent_id} |
GET | Yes | Full passport details | Advanced |
The issue links to /api/verify/ap_128094d3 which is the first endpoint (agent view).
3. Sample Request Confusion
The example in the PR shows:
{
"context": {
"agent_id": "ap_128094d3",
"policy_id": "payments.refund.v1",
"context": {
"amount": 50,
"currency": "USD"
}
}
}This is for policy verification, not for viewing an agent passport.
For the agent view endpoint, there's no request body - it's a simple GET request!
✅ Action Items
- Change endpoint from
/api/verify/policy/{policy}to/api/verify/{agent_id} - Change HTTP method from POST to GET
- Remove request body logic (no JSON marshaling needed)
- Update structs to match agent passport response format
- Simplify README to explain agent passports (not policy verification)
- Remove policy-related configuration and examples
- Update output formatting to show agent details (not decision data)
- Clarify this is viewing agent data, not authorizing actions
- Add note about policy verification being a separate example
💡 Suggested Example Output
APort Go Hello World Example
==============================
Fetching agent passport for: ap_128094d3
From: https://aport.io
Agent Passport:
===============
Agent ID: ap_128094d3
Name: HappyRefundBot Pro
Role: Snr. Refund Specialist
Status: active
Description:
AI-powered refund processing agent with advanced fraud detection
Capabilities:
- payments.refund (max_amount: 10000, currency: USD)
- inventory.adjust
- messaging.send (max_recipients: 10)
Limits:
Max actions/min: 60
Max export rows: 1000
Success! Agent passport retrieved.
📚 References
Agent View Endpoint: https://aport.io/api/verify/ap_128094d3
Sample Response: Returns full agent passport JSON
NOT the Policy Verification Endpoint: /api/verify/policy/{policy} (that's for authorization checks)
Summary
The code quality is good and follows Go best practices, but it's implementing the wrong feature. The issue asks for a simple "hello world" that views an agent's passport (GET request, no auth), but the PR implements policy verification (POST request, requires auth, complex request body).
To fix: Use the simpler /api/verify/{agent_id} GET endpoint instead of /api/verify/policy/{policy} POST endpoint.
This is actually a great policy verification example - it just belongs in a different location (like /examples/policy-verification/go/ or /examples/authorization/go/) rather than /examples/hello-world/go/.
|
Okay. I apologise for the misunderstanding. Will resolve the issues and get back soon. |
|
@uchibeke Made the required changes. Please review |
Summary
This PR adds a minimal, single-file Go script that demonstrates basic integration with the APort
/verifyendpoint, helping Go developers get started with APort in seconds.Please review the code and suggest any changes if required. Also please remember to add label Hacktoberfest-accepted
Closes #27
Changes Made
New Files Added:
examples/hello-world/go/main.go- Single-file Go script using only standard libraryexamples/hello-world/go/README.md- Comprehensive documentation with examplesexamples/hello-world/go/go.mod- Go module definitionexamples/hello-world/go/env.example- Environment configuration templateSuccess Criteria Met
/examples/hello-world/godirectorynet/http,encoding/json,fmt,log,os,io,bytes)Technology Stack
/api/verify/policy/{policy}endpointFeatures
APORT_BASE_URL,APORT_AGENT_ID,APORT_POLICYUsage Examples
Testing
Documentation
Includes comprehensive README with:
Related
Part of the APort integrations ecosystem to help developers quickly get started with APort verification in their Go applications.