Comments (4)
@JosteinLindhom To debug this, you will want to look in assignments/assignments_parser.go
. Suggest to add the problematic assignment.yml
example as a test case to figure out why it isn't providing parse error in the log, ref. Line 30:
err := yaml.Unmarshal(contents, &newAssignment)
(I think my recollection is that this function doesn't return an error for a yaml field (assignmentid
) that is missing a corresponding field in the struct. Which is should according to the documentation.)
from quickfeed.
If my recollection mentioned above is correct, then this is really annoying. Would be great if you can confirm this. Moreover, if that is the case, then readTestsRepositoryContent
will return partially initialized assignments
([]*qf.Assignment
), which may be written to the database. We should prevent "partially" filled assignments from being written to the database.
Regarding the particular issue of having to invoke UpdateAssignments
; the database code for this method has always been a bit problematic I think. I suggest to add some more test cases to try to trigger the particular scenario with "partial" assignments, and see if there is a problem with the implementation of said method. It looks like we have only a simple test TestUpdateAssignment
for this in gormdb_assignment_test.go
.
from quickfeed.
Jotting down my findings after taking a cursory look:
Seems like yaml.Unmarshal(...)
returns an error if the field has the incorrect type, e.g. order: "hello"
.
yaml.UnmarshalStrict(...)
will return an error if an included yaml field does not correspond to any struct fields.
However, we include fields such as title
and effort
for other tooling to generate README.md
As for the issue with UpdateAssignments
, I've found these issues with db.UpdateAssignments
:
- If any one assignment does not have
Order > 0
, the entire transaction is rolled back.
This explains the issue where no assignments were added when assignmentid
was used instead of order
return db.conn.Transaction(func(tx *gorm.DB) error {
for _, v := range assignments {
if err := check(tx, v); err != nil {
return err // if any assignment fails the check, rollback and stops processing assignments
}
...
}
}
- If any one assignment does not already exist, that assignment is created and the function returns.
This explains why I had to invoke the method three times:
return db.conn.Transaction(func(tx *gorm.DB) error {
for _, v := range assignments {
...
var assignment qf.Assignment
if tx.Model(&qf.Assignment{}).FirstOrInit(&assignment,
&qf.Assignment{
CourseID: v.CourseID,
Order: v.Order,
},
).RowsAffected == 0 {
// Zero rows affected indicates that the assignment does not exist
return tx.Model(&qf.Assignment{}).Create(v).Error // commits or rolls back transaction. no further assignments processed
}
...
}
}
from quickfeed.
PR #1002 makes the most trivial fix for a bad assignment.yml
file, which is the main thing we want to fix here, so that we can more easily discover why and which assignment.yml
file failed to parse correctly. We can also avoid multiple assignments in a single transaction, avoiding the other problem.
@JosteinLindhom Can you please add some tests for this stuff. Just commit to the same PR.
PS: Seems like something doesn't like that I used go 1.20 for GitHub workflows... (didn't have time to debug why... I hate workflows.)
from quickfeed.
Related Issues (20)
- [frontend] Long lines in test output causes lab results to "disappear"
- Increase deadline for streaming requests
- Upgrade dependencies and go version
- Update doc/teacher.md
- Bug in template run.sh scripts
- Remove ResponseController when connect-go support has been added
- Use installation event to create course HOT 1
- Use organization webhook events to accept member invites HOT 2
- Consider adding more streams
- Add support for parsing commit messages HOT 1
- `Course.dockerfile`
- Add privileged ports capabilities when installing binary
- Remove GRPCManager and (maybe also) MockGRPCManager? HOT 1
- Chore: Simplify Organization message type
- Add the `Repository` message type to `Group`, `Enrollment`.
- Duplicate tests cause scores to be calulated and stored incorrectly
- [Suggestion] Automatically assign reviewers for manually graded assignments HOT 3
- Teachers are not able to see students when editing groups
- [Frontend] Improve how manual review comments are displayed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quickfeed.