Git Product home page Git Product logo

aio-lib-target's Issues

Target SDK get calls failing with swagger client update

Expected Behaviour

Actual Behaviour

Error for GET calls - ' Request with GET/HEAD method cannot have body'
This is because of swagger client update to 3.10.2

Reproduce Scenario (including but not limited to)

Steps to Reproduce

Platform and Version

Sample Code that illustrates the problem

Logs taken while reproducing problem

Failing to Update A/B Activities

Expected Behaviour

Target SDK or Target API allow you to update Target A/B activities, including ones that have auto-allocate.

Actual Behaviour

Unable to update Target A/B activities with SDK or API.

Reproduce Scenario (including but not limited to)

Using this SDK

// Get and update single activity
const response = await targetClient.getABActivityById(395705);
const body = response.body;
await targetClient.updateABActivity(395705, body);

throws this error

error
[TargetSDK:ERROR_UPDATE_AB_ACTIVITY] Error: Conflict
    at _callee$ (C:\Git\TargetAPI\node_modules\swagger-client\dist\index.js:623:816)
    at tryCatch (C:\Git\TargetAPI\node_modules\regenerator-runtime\runtime.js:63:40)
    at Generator.invoke [as _invoke] (C:\Git\TargetAPI\node_modules\regenerator-runtime\runtime.js:293:22)
    at Generator.next (C:\Git\TargetAPI\node_modules\regenerator-runtime\runtime.js:118:21)
    at asyncGeneratorStep (C:\Git\TargetAPI\node_modules\@babel\runtime-corejs2\helpers\asyncToGenerator.js:5:24)
    at _next (C:\Git\TargetAPI\node_modules\@babel\runtime-corejs2\helpers\asyncToGenerator.js:27:9)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  status: 409,
  statusCode: 409,
  response: [Object]
}

Using HTTP API

In Postman, with this request https://mc.adobe.io/{{tenant}}/target/activities/ab/395705 that was given to me by your Postman collection from the documentation (no modifications made besides filling in variables), with body being the exact response from the corresponding Get request for ab activity, gives this error

error
{
    "httpStatus": 409,
    "requestId": "YqYAZftfoxjPU3F1ZKJHsGyPuzK2NAJo",
    "requestTime": "2021-04-16T19:47:29.076182Z",
    "errors": [
        {
            "errorCode": "VersionConflict.Resource",
            "message": "Cannot create/update auto-allocate activity with this version of API"
        }
    ]
}

Steps to Reproduce

Platform and Version

SDK
"@adobe/aio-lib-target": "^2.1.1"

API
application/vnd.adobe.target.v3+json

Node.js
v14.15.4

Sample Code that illustrates the problem

Here's the whole Node.js file reproducing it:

code
const sdk = require('@adobe/aio-lib-target');

(async () => {
    const client = await sdk.init('tenant', 'key', 'token');

    try {
      // Get single and update activity
      const response = await client.getABActivityById(395705);
      const body = response.body;
      await client.updateABActivity(395705, body);
    } catch(e) {
      console.log(e.message);
    }
})();

Logs taken while reproducing problem

An in-range update of fetch-mock is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye πŸ‘‹ and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency fetch-mock was updated from 9.3.1 to 9.4.0.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

fetch-mock is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Commits

The new version differs by 10 commits.

  • 3cdc7ba fixed broken tests
  • b1f33ec fix linting
  • 87a2758 Merge pull request #532 from chet-manley/feat-return-node-fetch-interface
  • d7a6577 feat: mock node-fetch's export pattern
  • 3500688 Merge pull request #526 from pabloosso/patch-1
  • 8c231ac Fixed typo
  • e25f30a Merge pull request #525 from willheslam/patch-1
  • 5817bbf Fix typo in mock_response.md
  • 41b238f Update cheatsheet.md
  • aa8311e Update cheatsheet.md

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of eslint-plugin-jest is breaking the build 🚨

The devDependency eslint-plugin-jest was updated from 23.1.0 to 23.1.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

eslint-plugin-jest is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Release Notes for v23.1.1

23.1.1 (2019-11-30)

Bug Fixes

  • no-focused-tests: detect table format uage of .only.each (#489) (d03bcf4)
Commits

The new version differs by 2 commits.

  • 6ffb998 chore(release): 23.1.1 [skip ci]
  • d03bcf4 fix(no-focused-tests): detect table format uage of .only.each (#489)

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Node.js TargetSDK:ERROR_GET_OFFER_BY_ID

While we are working on Adobe IO to get/update the offer in Adobe Target through Adobe IO Target library

Expected Behaviour

When calling getOfferById() function, the following error occurred:

Actual Behaviour

we are getting the below errors.
[TargetSDK: ERROR_GET_OFFER_BY_ID] Error: Not Acceptable
Target SDK error

Reproduce Scenario (including but not limited to)

Can be easily reproduced in the following steps

Steps to Reproduce

Download the zip file and keep the js file in a folder. (see attached targetInit.zip)
targetInit.zip
You will need to replace the access token to a valid access token in the targetInit.js file, the problem can be reproduced with any Target company with json offers in the Offer library.

Open a command prompt in the folder the targetInit.js file exists. Run the below command.
npm install @adobe/aio-lib-target
Post that run the below command.
node targetInit.js
Replicate the issue with the above steps.

We are trying to give solution using Adobe IO serverless architecture to update the Target Activity/Offers through Adobe IO Target library.

Platform and Version

Node.js latest version

Sample Code that illustrates the problem

see targetInit.js
const offer = await targetClient.getOfferById(offerID)

Logs taken while reproducing problem

It seems the root cause is the get Offer Content call. which fails with a 406.

curl --location --request GET 'https://mc.adobe.io/tatadigital/target/offers/content/458563'
--header 'Authorization: Bearer '
--header 'x-api-key: '

Returns
{
"httpStatus": 406,
"requestId": "KsYtjLDzfFsvvcG9DiYAmPMibqnHEC3I",
"requestTime": "2021-06-11T00:12:22.634272Z",
"errors": [
{
"errorCode": "Unsupported.Feature",
"message": "Unsupported offer type. The only supported type is: content",
"meta": {}
}
]
}

All the offers returned when listing the offers are of Type = json

Changing the URL above to https://mc.adobe.io/tatadigital/target/offers/json/458563'

returns
{
"id": 458563,
"name": "/birthday_offers/experiences/0/pages/0/zones/0/1623150537848",
"content":

{ "ShowOffers": "true", "count": "5" }
,
"modifiedAt": "2021-06-08T12:26:30Z"
}

The JAVAScript code needs to examine the type of the offer and make the appropriate backend API call.

The Swagger spec seems to have support for content but not for a variable to take the type.

There seems to be a discrepancy in the SDK function targetClient.getOfferById(offersArray[i].id) call in that, it also needs type to construct the correct URL to fetch the offer.

Workaround is to maybe call the adobe.io rest API directly, since that works fine as mentioned above.

Permalink
shete
Aditi Shete added a comment - 6 days ago - edited
Withe the token and api key provided for tatadigital, with Accepts set to application/vnd.adobe.target.v2+json

I was able to run the adobe.io call successfully to get offers.

curl -X GET
'https://mc.adobe.io/tatadigital/target/offers?limit=10'
-H 'authorization: Bearer '
-H 'cache-control: no-cache'
*-H 'Accept: application/vnd.adobe.target.v2+json' *
-H 'x-api-key: '

Please investigate the the node.js side code which uses the Swagger client to make the above call (which seems to be succeeding with the apikey and token provided.)

Node 14 no longer supported

Expected Behaviour

Using Node 14

Given the following code:

const aiolibtarget = require('@adobe/aio-lib-target')

console.log('Hi')

The following result should be produced:

Hi

Actual Behaviour

Using Node 14

Given the following code:

const aiolibtarget = require('@adobe/aio-lib-target')

console.log('Hi')

The following result is produced:

/Users/mgoberling/repos/adobe/my-utils/utils/api-mesh-test/node_modules/@swagger-api/apidom-error/cjs/ApiDOMAggregateError.cjs:7
class ApiDOMAggregateError extends AggregateError {
                                   ^

ReferenceError: AggregateError is not defined
    at Object.<anonymous> (/Users/mgoberling/repos/adobe/my-utils/utils/api-mesh-test/node_modules/@swagger-api/apidom-error/cjs/ApiDOMAggregateError.cjs:7:36)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)
    at Module.load (internal/modules/cjs/loader.js:979:32)
    at Function.Module._load (internal/modules/cjs/loader.js:819:12)
    at Module.require (internal/modules/cjs/loader.js:1003:19)
    at require (internal/modules/cjs/helpers.js:107:18)
    at Object.<anonymous> (/Users/mgoberling/repos/adobe/my-utils/utils/api-mesh-test/node_modules/@swagger-api/apidom-error/cjs/ApiDOMError.cjs:8:52)
    at Module._compile (internal/modules/cjs/loader.js:1114:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1143:10)

Reproduce Scenario (including but not limited to)

Steps to Reproduce

  • Use Node 14
  • Install @adobe/aio-lib-target in project
  • Create index.js like above
  • Try to run

Platform and Version

Node 14.21.3

Notes

AggregateError was introduced in Node 15

Add badges

Build badges etc, as required via the internal wiki checklist

An in-range update of fetch-mock is breaking the build 🚨


☝️ Important announcement: Greenkeeper will be saying goodbye πŸ‘‹ and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io


The devDependency fetch-mock was updated from 9.1.0 to 9.1.1.

🚨 View failing branch.

This version is covered by your current version range and after updating it in your project the build failed.

fetch-mock is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details

Commits

The new version differs by 2 commits.

  • cdfb3a9 Merge pull request #512 from wheresrhys/body-inspecting
  • 0806bfc inspect based on body

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

v3 Target API calls not working

Expected Behaviour

Target API Calls that use the v3 Accept-header ('Accept: application/vnd.adobe.target.v3+json') should be successful.

Actual Behaviour

When I try to call getABActivityById from my code, I get this error:

[TargetSDK:ERROR_GET_AB_ACTIVITY_BY_ID] Error: Conflict
    at _callee$ (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/swagger-client/dist/index.js:581:816)
    at tryCatch (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/regenerator-runtime/runtime.js:45:40)
    at Generator.invoke [as _invoke] (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/regenerator-runtime/runtime.js:271:22)
    at Generator.prototype.<computed> [as next] (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/regenerator-runtime/runtime.js:97:21)
    at asyncGeneratorStep (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)
    at _next (/Users/alexandraanton/_DATA/GIT_Repos/ADOBE-IO-TOOLS/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:27:9)
    at processTicksAndRejections (internal/process/task_queues.js:94:5) {
  status: 409,
  statusCode: 409,
  response: [Object]
}

Reproduce Scenario (including but not limited to)

I have code that leverages the adobe-io-target lib, and that makes calls to getActivities, getABActivityById, getXTActivityById as well as update activity API calls.

Steps to Reproduce

I have tried to fix the issue by changing the code to make another request intercept and add the necessary Accept headers. After this, it works. I am attaching the modified code here
index.js.zip
to give you an idea. Please have a look at getActivities, getABActivityById and getXTActivityById.

If the solution seems acceptable to you, I can create a PR to cover all API calls, otherwise please have a look and let me know your opinion.

Platform and Version

Current version

Sample Code that illustrates the problem

const exportActivity = (activity) => {
  return targetApi.initApi().then((sdk) => {
    if (activity.type === 'abt') {
      console.warn(chalk.red("Skipping activity"), activity)
      return Promise.resolve(() => { })
    }
    if (activity.type === 'ab') {
      return sdk.getABActivityById(activity.id);
    }
    if (activity.type === 'xt') {
      return sdk.getXTActivityById(activity.id);
    }
  })
}

Logs taken while reproducing problem

getActivities returns 0 results

Using the sample code:
const activities = await targetClient.getActivities({limit:5, offset:0})
I always get 0 results:
{ total: 0, offset: 0, limit: 5 }

Target API calls retuning HTTP 500 in Firefly Apps

Expected Behaviour

API calls from the AIO Target SDK shall work as expected when used in Firefly Apps.

Actual Behaviour

API calls like getOffers, getActivities are consistently sending Internal Server Error (HTTP 500) when invoked from Firefly Apps.

Reproduce Scenario (including but not limited to)

  • Use default code generated by Firefly App for Adobe Target actions.
  • Tried initializing the SDK directly from @adobe/aio-lib-target instead of @adobe/aio-sdk; didn't help.
  • I haven't verified this issue outside of a Firefly App yet but all direct Target REST APIs are working for my environment (double cheked via postman) as I have been using them earlier too.

Steps to Reproduce

  1. Create a new app in AIO Runtime using Firefly.
  2. Add Adobe Target API to the workspace in AIO with standard steps.
  3. Select "Adobe Target" when asked, "Which type of sample actions do you want to create?"
    ❯ β—‰ Adobe Target
    β—‰ Generic
  4. Make changes for required values like Target Tenant, etc. in the .env file.
  5. Invoke the Target API action which calls getActivities() by default and notice the response.
  6. Try a few more methods like getOffers, etc. and the response will be the same (500 Internal Server Error)

Platform and Version

AIO JS SDK for Target in Firefly Apps.

Sample Code that illustrates the problem

// Here's the default invocation code generated from Firefly:

const { Target } = require('@adobe/aio-sdk')
const targetClient = await Target.init(params.tenant, params.apiKey, token) 
const offers = await targetClient.getOffers({limit:5, offset:0})
const activities = await targetClient.getActivities({ limit: 5, offset: 0 })

Logs taken while reproducing problem

error: [TargetSDK:ERROR_GET_ACTIVITIES] Error: Internal Server Error
error: [TargetSDK:ERROR_GET_OFFERS] Error: Internal Server Error

Add FAQ to Doc Section

We've been seeing some issues raised here that's actually attributed to a permission issue in Admin Console. We should add this to our docs, likely in an FAQ session, as part of the doc to enable users to self-help.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.