Closed NikolayMetchev closed 5 months ago
Hi @NikolayMetchev ,
Hmmm. I'm unable to replicate. Sent you an email.
Hmm. I'm am still unable to replicate.
Here's my java class that I'm running to do the import; it imported my test user just fine, though they were inactive. Can you please let me know how your java api call differed (or try running mine and let me know if it works)?
package testadd;
import java.util.ArrayList;
import com.inversoft.rest.ClientResponse;
import io.fusionauth.client.FusionAuthClient;
import io.fusionauth.domain.User;
import io.fusionauth.domain.api.user.ImportRequest;
public class AddUser {
public static void main(String args[]) {
String apiKey = "OBFUSCATED";
FusionAuthClient client = new FusionAuthClient(apiKey, "https://paxos-dev.fusionauth.io");
ImportRequest request = new ImportRequest();
request.users = new ArrayList<User>();
User user = new User();
user.email = "testdan@example.com";
user.password = "password";
request.users.add(user);
ClientResponse cr = client.importUsers(request);
if (cr.wasSuccessful()) {
System.out.println("success");
} else {
System.out.println("error");
System.out.println(cr.errorResponse);
System.out.println(cr.exception);
}
}
}
I can't seem to reproduce the error either. However the stack trace is real. It did only happen once for me and then I changed the code to add the id and it started working. I am sorry I can't be more helpful.
Thanks @NikolayMetchev
I believe you that it was a real stack trace :)
Since neither of us can replicate this, I'll leave it up for a few weeks and see if anyone else chimes in.
Hi @NikolayMetchev. This one is quite odd because it should be impossible to insert a User
object into the FusionAuth database without an id
. Furthermore, it should be impossible to visit the /admin/user/manage
page in the FusionAuth admin UI without an id
.
I've actually seen this stack trace in the logs before and similar to you and @mooreds, I have not yet been able to replicate it. The unfortunate part with not being able to replicate the issue, is that it cannot be fixed from the stack trace alone. That stack trace is nested deep inside our template rendering engine, which is called at the very end of the request.
If you see this error again, please take a database dump immediately without making any changes to anything and attach the dump to this issue. That will help us investigate further.
Also, if you find that you are able to import users and have them exist without the id
column in the database, definitely send us the JSON you are using for the /api/user/import
call.
What's even stranger is that the user
object that is causing the error in FreeMarker is retrieved by userId in the action. 🤔
Closing this issue as not reproducible. I still can't reproduce it today :-)
Missing out id from user on importUsers results in internal server error
Description
doing a POST on /api/user/import with a user that doesn't have an id specified results in internal exception.
Affects versions
1.23.3
Steps to reproduce
I used the Java api to create a POST on /api/user/import I forgot to populate the id field of the User object and the result was an internal exception rather than a helpful error message
Expected behavior
The API should return an error explaining that the ID is required field.
Screenshots
FTL stack trace ("~" means nesting-related):
Failed at: ${user.id} [in template "WEB-INF/templates/admin/user/manage.ftl" at line 28, column 21] ~ Reached through: #nested [in template "WEB-INF/templates/_layouts/admin.ftl" in macro "head" at line 151, column 3] ~ Reached through: @layout.head [in template "WEB-INF/templates/admin/user/manage.ftl" at line 25, column 3] ~ Reached through: #nested [in template "WEB-INF/templates/_layouts/admin.ftl" in macro "html" at line 15, column 3] ~ Reached through: @layout.html [in template "WEB-INF/templates/admin/user/manage.ftl" at line 24, column 1]
at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134) at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:481) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:401) at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:370) at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:100) at freemarker.core.DollarVariable.accept(DollarVariable.java:63) at freemarker.core.Environment.visit(Environment.java:370) at freemarker.core.Environment.invokeNestedContent(Environment.java:620) at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60) at freemarker.core.Environment.visit(Environment.java:370) at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:876) at freemarker.core.Environment.invokeMacro(Environment.java:812) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:84) at freemarker.core.Environment.visit(Environment.java:370) at freemarker.core.Environment.invokeNestedContent(Environment.java:620) at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60) at freemarker.core.Environment.visit(Environment.java:370) at freemarker.core.Environment.invokeMacroOrFunctionCommonPart(Environment.java:876) at freemarker.core.Environment.invokeMacro(Environment.java:812) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:84) at freemarker.core.Environment.visit(Environment.java:334) at freemarker.core.Environment.visit(Environment.java:340) at freemarker.core.Environment.process(Environment.java:313) at freemarker.template.Template.process(Template.java:383) at org.primeframework.mvc.freemarker.DefaultFreeMarkerService.render(DefaultFreeMarkerService.java:76) ... 35 common frames omitted 2021-02-15 3:11:19.896 PM ERROR org.primeframework.mvc.servlet.PrimeFilter - Error encountered org.primeframework.mvc.freemarker.FreeMarkerRenderException: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing: ==> user.id [in template "WEB-INF/templates/admin/user/manage.ftl" at line 28, column 23]
Platform
(Please complete the following information)
Additional context
https://paxos-dev.fusionauth.io/