aws / aws/aws-appsync-community
invokeModel from '@aws-appsync/utils/ai' result in 'Value for field '$[method]' not found.'
- Dominant language
- HTML
- Stars
- 507
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
I am trying out appsync bedrock integration using '@aws-appsync/utils/ai'
But I am experiencing the following issue:
`Value for field '$[method]' not found.`
Please find below all the details:
**Version**: "@aws-appsync/utils": "2.0.3"
**Appsync javascript function code:**
```typescript
import { runtime, util } from "@aws-appsync/utils";
import { invokeModel } from "@aws-appsync/utils/ai";
export function request(ctx) {
const { nameToUse, cached } = ctx.stash;
if (cached) {
runtime.earlyReturn(ctx, { skipTo: "NEXT" });
}
const prompt = `
REDACTED
`.trim();
return invokeModel({
modelId: ctx.env.BEDROCK_MODEL_ID,
body: { inputText: prompt },
});
}
export function response(ctx) {
if (ctx.error) {
util.error(ctx.error.message, ctx.error.type, ctx.result);
}
if (!ctx.result) {
util.error("Resolve service error", "InternalServerError");
}
const out = JSON.parse(ctx.result.results[0].outputText);
ctx.stash.transliterated = out.unicode.trim();
return ctx.result;
}
```
**Appsync logs:**
```
{
"logType": "RequestFunctionEvaluation",
"fieldName": "assignName",
"resolverArn": "arn:aws:appsync:us-east-1:{redacted}:apis/{redacted}/types/Mutation/resolvers/assignName",
"functionName": "ResolveNameFunction",
"fieldInError": true,
"evaluationResult": {
"operation": "InvokeModel",
"modelId": "amazon.nova-micro-v1:0",
"body": "{\"inputText\":\"REDACTED\"}"
},
"parentType": "Mutation",
"path": [
"assignName"
],
"requestId": "a0f5b7ed-8b64-4b59-b95e-f5488b53b624",
"context": {
"arguments": {
"locales": [
"en-US-u-fw-mon-mu-celsius",
"fr-FR-u-fw-mon-mu-celsius"
]
},
"prev": {},
"stash": {
"nameToUse": "Nicolas",
"user": {
"id": "f094f76d-8042-4147-8123-59cae80a15e9",
"legalFirstName": "Nicolas"
}
},
"outErrors": []
},
"errors": [
"Value for field '$[method]' not found."
],
"graphQLAPIId": "{redacted}",
"functionArn": "arn:aws:appsync:us-east-1:{redacted}:apis/{redacted}/functions/oi4omr5ocnbvfkpmk45noiajvy"
```
Let me know if you need anything else,
Thank you.
Contributor guide
Research direction
Start with the invokeModel entry point from @aws-appsync/utils/ai and the AppSync JavaScript function shown in the report, then inspect the RequestFunctionEvaluation log and its '$[method]' error. Reproduce the call using @aws-appsync/utils 2.0.3 with the logged modelId and body; done means the function completes without that error and produces the expected response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, graphql, typescript
- Domain
- api, backend, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100