You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@fineract.apache.org by "rymghosn (via GitHub)" <gi...@apache.org> on 2026/07/30 13:56:11 UTC
[PR] FINERACT-2724: Allocate Cash - Adjust the error message when amount is not an integer [fineract]
rymghosn opened a new pull request, #6203:
URL: https://github.com/apache/fineract/pull/6203
The teller cashier "allocate cash" endpoint (POST /tellers/{tellerId}/cashiers/{cashierId}/allocate) returned an unclear/generic error when
txnAmount was not a valid number, instead of a proper validation message.
Changes made:
- CashierTransactionRequest.txnAmount (and its corresponding Swagger schema in TellerApiResourceSwagger) is changed from BigDecimal to String, so
a malformed value reaches the deserializer instead of failing earlier at JSON-binding time.
- TellerCommandFromApiJsonDeserializer now catches the parse failure when extracting txnAmount and raises a PlatformApiDataValidationException
with a clear "Amount must be a number" message, reusing the existing validation.msg.invalid.decimal.format error code.
This PR( https://issues.apache.org/jira/browse/FINERACT-2724 )
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2724: Allocate Cash - Adjust the error message when amount is not an integer [fineract]
Posted by "rymghosn (via GitHub)" <gi...@apache.org>.
rymghosn commented on code in PR #6203:
URL: https://github.com/apache/fineract/pull/6203#discussion_r3736271649
##########
fineract-core/src/test/java/org/apache/fineract/infrastructure/core/exception/HttpMessageNotReadableErrorControllerTest.java:
##########
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.infrastructure.core.exception;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.exc.InvalidFormatException;
+import jakarta.ws.rs.core.Response;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import org.apache.fineract.infrastructure.core.data.ApiParameterError;
+import org.junit.jupiter.api.Test;
+import org.springframework.http.converter.HttpMessageNotReadableException;
+
+/**
+ * Tests for {@link HttpMessageNotReadableErrorController}, in particular the FINERACT-2724 behaviour where a
+ * non-numeric value submitted for a numeric field is reported as a field-specific "not a valid number" validation error
+ * rather than the generic invalid-JSON error.
+ */
+public class HttpMessageNotReadableErrorControllerTest {
+
+ private final HttpMessageNotReadableErrorController controller = new HttpMessageNotReadableErrorController();
+
+ @Test
+ public void nonNumericValueForNumericFieldReturnsFieldSpecificValidationError() throws Exception {
+ final InvalidFormatException invalidFormatException = invalidFormatExceptionFor("not-a-number", BigDecimal.class);
+ invalidFormatException.prependPath(HttpMessageNotReadableErrorControllerTest.class, "txnAmount");
+ final HttpMessageNotReadableException exception = new HttpMessageNotReadableException("JSON parse error", invalidFormatException);
Review Comment:
No — `(String, Throwable)` is the one to use; the other overload just adds an unused `HttpInputMessage`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2724: Allocate Cash - Adjust the error message when amount is not an integer [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on PR #6203:
URL: https://github.com/apache/fineract/pull/6203#issuecomment-5193155354
> @adamsaghy Kindly review my concerns after applying the changes.
AI? :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2724: Allocate Cash - Adjust the error message when amount is not an integer [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #6203:
URL: https://github.com/apache/fineract/pull/6203#discussion_r3735855944
##########
fineract-core/src/test/java/org/apache/fineract/infrastructure/core/exception/HttpMessageNotReadableErrorControllerTest.java:
##########
@@ -0,0 +1,98 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.fineract.infrastructure.core.exception;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+
+import com.fasterxml.jackson.core.JsonFactory;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.exc.InvalidFormatException;
+import jakarta.ws.rs.core.Response;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import org.apache.fineract.infrastructure.core.data.ApiParameterError;
+import org.junit.jupiter.api.Test;
+import org.springframework.http.converter.HttpMessageNotReadableException;
+
+/**
+ * Tests for {@link HttpMessageNotReadableErrorController}, in particular the FINERACT-2724 behaviour where a
+ * non-numeric value submitted for a numeric field is reported as a field-specific "not a valid number" validation error
+ * rather than the generic invalid-JSON error.
+ */
+public class HttpMessageNotReadableErrorControllerTest {
+
+ private final HttpMessageNotReadableErrorController controller = new HttpMessageNotReadableErrorController();
+
+ @Test
+ public void nonNumericValueForNumericFieldReturnsFieldSpecificValidationError() throws Exception {
+ final InvalidFormatException invalidFormatException = invalidFormatExceptionFor("not-a-number", BigDecimal.class);
+ invalidFormatException.prependPath(HttpMessageNotReadableErrorControllerTest.class, "txnAmount");
+ final HttpMessageNotReadableException exception = new HttpMessageNotReadableException("JSON parse error", invalidFormatException);
Review Comment:
Is there a different constructor, that we can use?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2724: Allocate Cash - Adjust the error message when amount is not an integer [fineract]
Posted by "rymghosn (via GitHub)" <gi...@apache.org>.
rymghosn commented on PR #6203:
URL: https://github.com/apache/fineract/pull/6203#issuecomment-5193102039
@adamsaghy Kindly review my concerns after applying the changes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2724: Allocate Cash - Adjust the error message when amount is not an integer [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy commented on code in PR #6203:
URL: https://github.com/apache/fineract/pull/6203#discussion_r3703555344
##########
fineract-branch/src/main/java/org/apache/fineract/organisation/teller/api/TellerApiResourceSwagger.java:
##########
@@ -373,7 +373,7 @@ private PostTellersTellerIdCashiersCashierIdAllocateRequest() {
@Schema(example = "USD")
public String currencyCode;
@Schema(example = "5000")
- public BigDecimal txnAmount;
+ public String txnAmount;
Review Comment:
This seems incorrect... Please dont change the data type. BigDecimal is the correct to be used.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2724: Allocate Cash - Adjust the error message when amount is not an integer [fineract]
Posted by "rymghosn (via GitHub)" <gi...@apache.org>.
rymghosn commented on PR #6203:
URL: https://github.com/apache/fineract/pull/6203#issuecomment-5330092636
@adamsaghy Just to confirm, I’ve used the (String, Throwable) constructor since the other overload includes an unused HttpInputMessage.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] FINERACT-2724: Allocate Cash - Adjust the error message when amount is not an integer [fineract]
Posted by "adamsaghy (via GitHub)" <gi...@apache.org>.
adamsaghy merged PR #6203:
URL: https://github.com/apache/fineract/pull/6203
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@fineract.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org