I am using Dynamodb to perform the Add operation of new user, but I got some ConditionalCheckFailedException while saving the data.
I checked online and got to knew , like if we are using some condition then there might be a chance that we are conflicting with the data.
So I refactor my code and remove the saveExpression.setConditionalOperator(ConditionalOperator.AND) condition.
But After that I am getting the same issue:
{
"errorCode": 500,
"message": "The conditional request failed (Service: AmazonDynamoDBv2; Status Code: 400; Error Code: ConditionalCheckFailedException; Request ID: LN5P87FREI8SP1EIG4C9O60OUVVV4KQNSO5AEMVJF66Q9LSMANOG; Proxy: null)"
}
I want to know what are the other factor that raised this issue ?
Attaching my DB code :
#Override
public Optional<Item> addUser(#NonNull final Item userItem) {
DynamoDBSaveExpression saveExpression = new DynamoDBSaveExpression();
Map<String, ExpectedAttributeValue> expectedAttributes =
Map.of("UserId", new ExpectedAttributeValue(false));
saveExpression.setExpected(expectedAttributes);
super.save(userItem, saveExpression);
return super.load(Item.class, userItem.getUserId())
Related
am quite new to flutter and my code is pretty much a mess but can anyone explain why db. update doesn't work, whenever I try to update it throws this error
"error when trying to update"(https://i.stack.imgur.com/4cCdt.png)
"code"(https://i.stack.imgur.com/yDoIl.png)
"UI" (https://i.stack.imgur.com/HkahR.png)
all that its supposed to do is when the save icon is pressed it takes input from both title and body and saves them as it is shown above, but instead it throws the error when trying to update. can anyone help please ?
this how my update function goes:
Future update(Note note) async {
final db = await instance.database;
final id = await db.update(
tableNotes,
note.toJson(),
where: '${NoteFields.id} = ?',
whereArgs: [note.id]);
return note.copy(id: id);
}
As per your screenshot, the data you are passing is null, that's why it is showing an error, before updating check what data you are sending.
solved it by adding the parameter id which then specifyed what it was adding txt and txt2 to
This is code section.. companyStatus: userCtx.user.category this section is generating error in the code. This field is actually enum type field in the schema.graphql
Can anyone please help me how to write that section? companyName is working fine, but getting error from company Status.
ERROR : companyType has an invalid value, this is the error
var input = {
companyName: userCtx.user.company,
companyStatus: userCtx.user.status
createdAt: new Date().toISOString()
}
I solved the issue. The code was all ok.
My Schema was
companyStatus {
pending
active
inactive
}
In the code where I was receiving the enum value
companyStatus: userCtx.user.status
userCtx.user.status value was previously Pending, P in caps, so that was the issue. When I changes Pending to pending, it got solved. Thanks.
My question is that when I create the second state, Corda throws a exception. And here is exception: "message": "net.corda.core.flows.UnexpectedFlowEndException: Counterparty sent session rejection message at unexpected time with message Unable to establish session". But the first state can store in Corda's default database.
So it is weird.
first state:[
{
"foud_name": "23",
"financing_name":"23",
"financing_project":"23",
"company_name":"23",
"data_producer":"23",
"attachment_name":"23",
"attachment_type":"23",
"attachment_id":"23"
}
]
When I store the second , It throws an exception:
{
"timestamp": "2018-08-24T09:47:02.654+0000",
"status": 500,
"error": "Internal Server Error",
"message": "net.corda.core.flows.UnexpectedFlowEndException: Counterparty sent session rejection message at unexpected time with message Unable to establish session",
"path": "/api/v1/resarch-attachment"
}
This error message indicates that:
As part of a flow, you are sending a message to a counterparty
The counterparty has a response flow registered to respond to the flow that is sending the message, but it doesn't expect to receive a message at this time
There are several reasons this could happen. The response flow may already have ended, or it may not be expecting to receive a message at this time.
You say that the error message only happens the second time. With the details I have, I'd hypothesise that your initiating flow is trying to make the counterparty to invoke the response flow multiple times. Something like:
#InitiatingFlow
#StartableByRPC
class InitiatorFlow(val counterparty: Party) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
val counterpartySession = initiateFlow(counterparty)
(0..99).forEach {
counterpartySession.send("My payload.")
}
}
}
#InitiatedBy(InitiatorFlow::class)
class ResponderFlow(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
counterpartySession.receive<String>()
}
}
This will not work. When you start an initiating flow, it is given a flow ID. This ID is used when communicating with counterparties to tell them which response flow to use:
If the counterparty has never received a message from a flow with this ID, it will create a new instance of the response flow
If the counterparty has received a message from a flow with this ID before, it will continue using this instance
If this flow instance has finished running, it will not create a new instance, but assume there has been a mistake, giving the error message you see above
Instead, you'd need to use subflows to create a new flow ID for each communication with the counterparty. Something like:
#InitiatingFlow
#StartableByRPC
class InitiatorFlow(val counterparty: Party) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
(0..99).forEach {
subFlow(SendMessageFlow(counterparty))
}
}
}
#InitiatingFlow
class SendMessageFlow(val counterparty: Party) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
val counterpartySession = initiateFlow(counterparty)
counterpartySession.send("My payload.")
}
}
#InitiatedBy(SendMessageFlow::class)
class ResponderFlow(val counterpartySession: FlowSession) : FlowLogic<Unit>() {
#Suspendable
override fun call() {
counterpartySession.receive<String>()
}
}
When using extensions in the Graph API:
graphUser = graphClient.Users.Request().AddAsync(graphUser).Result;
OpenTypeExtension newExtension = new OpenTypeExtension()
{
ExtensionName = "CustomName",
AdditionalData = new Dictionary<string, object>
{ { "CustomID", user.CustomID }
}
};
graphClient.Users[graphUser.UserPrincipalName]
.Extensions
.Request()
.AddAsync(newExtension)
.Wait();
I randomly get these errors:
Code: AccessDenied
Message: Access Denied
Sometimes it works, sometimes it doesn't. I can't seem to find a correlation.
When I step trough the code in the debugger it works more often then if I run it without interruption. But if I add a sleep between the lines (to account for processing delay), it doesn't fix the issue.
The application has all the required rights to access the API.
The issue isn't solely in the POST, but also on the GET as illustrated in the code sample below which results in the same error.
User user = graphClient.Users[userName]
.Request()
.GetAsync()
.Result;
user.Extensions = graphClient.Users[userName]
.Extensions
.Request()
.GetAsync()
.Result;
Does anyone have experience with this issue? Thanks in advance!
EDIT:
I figured out that once the errors start showing, the user needs to be deleted. Errors on one user don't necessarily mean errors on another user.
EDIT 2:
I also posted this as an issue on GitHub. Here you can find more information about this problem. It's now labeled as a bug.
It turns out that the User Principal Name is a cached reference.
Since I was running tests, meaning recreating the same test user a lot, the reference UPN was pointing to the old user object resulting in the Access Denied errors.
The issue can be avoided by using the Id of the object, like this:
graphClient.Users[graphUser.Id]
.Extensions
.Request()
.AddAsync(newExtension)
.Wait();
I believe the team is going to fix the reference bug, but I can't speak for them of course. In either case I would recommend using the Id attribute to be sure.
Based on the test, when we create a new user in Azure Active Directory, it seems that there is some delay we can operate for that user. Even the user is returned successfully when I using the Graph to filter the user, it still may failed when I add the extension to that user.
For this issue, I added a line of addition code to make the current thread sleep and then it works.
var userPrincipalName = "userPrincipalName8#adfei.onmicrosoft.com";
var graphUser = new User() { AccountEnabled = true, MailNickname = "MailNickname", UserPrincipalName = userPrincipalName, DisplayName = "userPrincipalName", PasswordProfile = new PasswordProfile() { Password = "islkdifde123!", ForceChangePasswordNextSignIn = false } };
graphUser = graphClient.Users.Request().AddAsync(graphUser).Result;
OpenTypeExtension newExtension = new OpenTypeExtension()
{
ExtensionName = "CustomName",
AdditionalData = new Dictionary<string, object>
{
{ "CustomID", "abc" }
}
};
Thread.Sleep(4000);
graphClient.Users[graphUser.UserPrincipalName]
.Extensions
.Request()
.AddAsync(newExtension)
.Wait();
However the detailed error message for this issue should be code=ResourceNotFound,message=User not found. Please check whether the error is same and this workaround is helpful.
When I send queries to Solr using solrj, I sometimes get SolrException's thrown. When I dig through the exception, it just says "Bad Request", and gives the HTTP return code (which is 400).
When I take the request URL and put it in my browser, I was able to see a richer error message. The browser displays an error message saying one of the fields names is not valid.
I would like to be able to capture this inside my log file. I was able to capture this by copying all the parameters to an Apache HTTP Client POST request (I'm using POST and not GET because GET made the URL too long) and re-executing the request, but this is inefficient. Is there a way to get error message out of SolrException directly?
Here's what I'm doing:
catch (SolrServerException e) {
if(e.getRootCause() instanceof SolrException) {
SolrException ee = (SolrException) e.getRootCause();
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(SOLR_URL);
// copy params over
Iterator<String> iter = request.getParams().getParameterNamesIterator();
while(iter.hasNext()) {
String p = iter.next();
method.setParameter(p, request.getParams().get(p));
}
int statusCode;
try {
// re execute and display the error message
statusCode = client.executeMethod(method);
logger.error(method.getResponseBodyAsString());
} catch (Exception e1) {
// TODO Auto-generated catch block
}
}
These messages aren't available via SolrJ. You can see them in solr's log file, but there is no way to capture them in your client, since solr only returns the 400 error status with a generic message to the client :(