Code Monkey home page Code Monkey logo

Comments (7)

RyanFitzSimmonsAK avatar RyanFitzSimmonsAK commented on August 29, 2024

Hi @delhi09, thanks for reaching out. Since you received a NextToken, I suspect what's happening here is that pagination is taking place before filtering. You're using the --no-paginate flag, so if your OPT_OUT contact is not in the first page of results, getting no results back makes sense. If you remove that, or continue paginating, what's the response look like?

from aws-cli.

delhi09 avatar delhi09 commented on August 29, 2024

Hi @RyanFitzSimmonsAK , thank you for your suggestion. I tried it, but unfortunately, it didn't change the result.

$ aws sesv2 list-contacts --contact-list-name=TestContactList --filter="FilteredStatus=OPT_OUT,TopicFilter={TopicName=test-topic,UseDefaultIfPreferenceUnavailable=true}" --region us-east-1
{
    "Contacts": [],
    "NextToken": “xxx”
}

from aws-cli.

RyanFitzSimmonsAK avatar RyanFitzSimmonsAK commented on August 29, 2024

What if you continue to paginate using the NextToken?

from aws-cli.

delhi09 avatar delhi09 commented on August 29, 2024

Hi @RyanFitzSimmonsAK , I apologize for the delay in my response. Thank you for your suggestion.

I tried pagination 10 times as follows. However, the "Contacts" field was empty in all results.

$ aws sesv2 list-contacts --contact-list-name=TestContactList --filter="FilteredStatus=OPT_OUT,TopicFilter={TopicName=test-topic,UseDefaultIfPreferenceUnavailable=true}" --region us-east-1
{
    "Contacts": [],
    "NextToken": "xxx"
}
$ aws sesv2 list-contacts --contact-list-name=TestContactList --filter="FilteredStatus=OPT_OUT,TopicFilter={TopicName=test-topic,UseDefaultIfPreferenceUnavailable=true}" --next-token xxx --region us-east-1
{
    "Contacts": [],
    "NextToken": "yyy"
}
$ aws sesv2 list-contacts --contact-list-name=TestContactList --filter="FilteredStatus=OPT_OUT,TopicFilter={TopicName=test-topic,UseDefaultIfPreferenceUnavailable=true}" --next-token yyy --region us-east-1
{
    "Contacts": [],
    "NextToken": "zzz"
}

from aws-cli.

RyanFitzSimmonsAK avatar RyanFitzSimmonsAK commented on August 29, 2024

Are you paginating until there isn't a NextToken in the response?

from aws-cli.

github-actions avatar github-actions commented on August 29, 2024

Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.

from aws-cli.

delhi09 avatar delhi09 commented on August 29, 2024

Hi @RyanFitzSimmonsAK , thank you for your suggestion. I created the following Python script and verified your suggestion.

import subprocess
import json
import time

request_count = 0

cmd = [
    "aws",
    "sesv2",
    "list-contacts",
    "--contact-list-name=TestContactList",
    "--filter=FilteredStatus=OPT_OUT,TopicFilter={TopicName=test-topic,UseDefaultIfPreferenceUnavailable=true}",
    "--region",
    "us-east-1",
]
output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
result = output.stdout.decode("utf-8")
next_token = json.loads(result)["NextToken"]
request_count += 1

while True:
    time.sleep(5)
    cmd = [
        "aws",
        "sesv2",
        "list-contacts",
        "--contact-list-name=TestContactList",
        "--filter=FilteredStatus=OPT_OUT,TopicFilter={TopicName=test-topic,UseDefaultIfPreferenceUnavailable=true}",
        "--region",
        "us-east-1",
        "--next-token",
        next_token,
    ]
    output = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    result = json.loads(output.stdout.decode("utf-8"))
    next_token = result["NextToken"]
    request_count += 1
    print("request count: ", request_count, "contacts: ", result["Contacts"], "next_token: ", next_token[0:10])
    if "NextToken" not in result or not result["NextToken"]:
        break

print("finished. request count: ", request_count)

I aborted the script because it seemed like it was going to run indefinitely.

Generally, the results showed contacts are empty, but there were a few instances where email addresses were found on some pages. Could you please explain how this is supposed to work?

console log1

request count:  39 contacts:  [] next_token:  AYADeJxWUG
request count:  40 contacts:  [] next_token:  AYADeHByJv
request count:  41 contacts:  [{'EmailAddress': '[email protected]', 'TopicPreferences': [{'TopicName': 'test-topic', 'SubscriptionStatus': 'OPT_OUT'}], 'UnsubscribeAll': False, 'LastUpdatedTimestamp': '2024-05-31T14:22:34.379000+09:00'}] next_token:  AYADeJqWAX
request count:  42 contacts:  [] next_token:  AYADeCqJFg
request count:  43 contacts:  [] next_token:  AYADeDGpKA

console log2

request count:  86 contacts:  [] next_token:  AYADeH3wtH
request count:  87 contacts:  [] next_token:  AYADeEnwYs
request count:  88 contacts:  [{'EmailAddress': '[email protected]', 'TopicPreferences': [{'TopicName': 'test-topic', 'SubscriptionStatus': 'OPT_OUT'}], 'UnsubscribeAll': False, 'LastUpdatedTimestamp': '2024-06-05T10:55:37.937000+09:00'}] next_token:  AYADeOuiB1
request count:  89 contacts:  [] next_token:  AYADeNXxLv
request count:  90 contacts:  [] next_token:  AYADeA9Kbs

from aws-cli.

Related Issues (20)

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.