apache / apache/grails-core

Command object LazyMap databinding not working in grails 3.3.7

Open
#11,245 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

We have application running on grails 2.2.4/java 1.7 and we are upgrading to grails 3.3.7/java1.8. Running the application on grails 3.3.7 we are noticing in a particular case the parameters to command object databinding is not working, same code just runs fine in grails 2.2.4

I have created a repo in github with a sample app reproducing the issue , containing the codebase for both grails 2.2.4(data-binding works fine) and grails 3.3.7(data-binding issue, with error in command object).

GitHub repo URL is https://github.com/swzaidi/sample

I will also inline the HTTP request data and relevant code snippet from sample app for your quick reference.

HTTP Request data

student.id: 1000
courses[1000].course.id: 1000
courses[1001].course.id: 1001
class EnrollmentController {

def save(EnrollmentCommand cmd) {

println "+++++++ cmd has errors" + cmd.hasErrors()
println "+++++++ cmd errors " + cmd.errors

}

}
class EnrollmentCommand {

Student student
Map courses = MapUtils.lazyMap(
new HashMap(),
FactoryUtils.instantiateFactory( CourseCommand ) )
}

class CourseCommand {
Course course
}
DataBinding error in grails 3.3.7

Error in object 'student.EnrollmentCommand': codes []; arguments []; default message [No such property: course.id for class: student.CourseCommand
Possible solutions: course]
DataBinding works fine in grails 2.2.4. Please see the below screenshot

intellij debugger screenshot

I will appreciate any insight on this issue and any idea on how to resolve it will be great.

Thanks, Shiraz

### Environment Information

- **Operating System**: Linux
- **Grails Version:** 3.37
- **JDK Version:** java 1.8
- **Container Version (If Applicable):** TODO

### Example Application

GitHub repo URL is https://github.com/swzaidi/sample

Contributor guide

Open the contributing guide

Research direction

Start with the linked sample repository and compare the Grails 2.2.4 and 3.3.7 versions, focusing on EnrollmentController, EnrollmentCommand, and CourseCommand. Reproduce the request with student.id and courses[1000].course.id, then investigate why Grails 3.3.7 reports “No such property: course.id”; done means the command object binds these nested map values without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.