How long?
704 characters, 47 lines.
That shouldn't be a problem. The limit is 4000 characters.
If it was, it is likely I would've gotten the corresponding error. But the server does not respond to the update request, at all. I can't create a new computed attribute with this body as well. I can, however, create a simple computed attribute with these parameters:
1
;Number
.That means it's probably not a database issue?
Here's my attribute body.
var checkIgnition = function () {
!empty(ignition) ? !ignition ? false : true : null
}
var checkRPM = function () {
!empty(rpm) ? rpm < 1000 ? true : false : null
}
var validator = function() {
empty(checkIgnition())
?
empty(checkRPM())
?
null
:
false
:
empty(checkRPM())
?
false
:
checkIgnition() && checkRPM()
}
validator()
?
empty(lastIdleHours)
?
empty(hours)
?
0
:
0
:
empty(hours)
?
lastIdleHours
:
lastIdleHours + (hours - lastHours)
:
empty(lastIdleHours)
?
0
:
lastIdleHours
And a snippet of my config:
<entry key='processing.computedAttributes.localVariables'>true</entry>
<entry key='processing.computedAttributes.loops'>true</entry>
<entry key='processing.computedAttributes.deviceAttributes'>true</entry>
<entry key='processing.computedAttributes.lastAttributes'>true</entry>
<entry key='processing.computedAttributes.newInstanceCreation'>true</entry>
Perhaps you can try and reproduce on your instance? Or give a hint?
Saved for me just fine on the latest official release.
It seems there's something regarding our setup; it can't just 'not work' out of nowhere.
I'll ask my colleague to try and enable SQL query logging on the DBMS to try and see if there's a query coming through. I'll post here with the result.
Are you sure you're using an official release without any code modificiations?
The issue appeared on the latest 6.6 release (was working in the past on the same build), so I tried and compiled from source the last master (a4adc44d800bea68a7800325e62049ff5d922192 at the time) build. Currently using that.
You have not answered my question.
I'm sorry, I believe the end of the workday has affected my mental capabilities at the time.
Right now, I'm not using the latest official release.
I believe I have found a clue.
For some reason, my Traccar cannot save an attribute if it contains a function that requires no parameters, like this:
var foo = function () { 1+1 }
However, it can save the following attribute:
var foo = function (x) { 1+1 }
Is a computed attribute being checked or executed before being updated in the database?
UPD: A workaround?
JEXL Syntax allows for several ways to define a function. If I do this:
var foo = () -> { 1+1 }
Then it saves just fine. What kind of stupidity is this?
We don't check any syntax when we save an attribute. It's just a string. So I very strongly suspect you have some code customization you're not telling us about.
I assure you, this is not the case here. Even on the latest official release (release! Not even preview!) the issue occurs.
I red-eyed through the logs and spotted the following line that occurs when I successfully save an attribute (given I use the () -> {}
syntax)
2025-04-08 23:19:20 WARN: Failed to store action edit
The database machine has got free space left, so I'm lost on how it fails to store. Can you give me a hint?
I checked the network traffic. It appears that the tracker-server acknowledges that it got the PUT request, but only sends SYNs and ACKs, no reply whatsoever. I decided to put some debug logging here and there in the AttributeResource, particularly in update method, and it seems that the request never even reaches this point!
As you can see, no Update
.
When a request is received, what part of code is called before it's handed over to AttributeResource? Where do I do debugging?
I've been working on rather large computed attributes, and I've encountered an issue where they just.. don't save?
The PUT API call (attributes/computed/{id}) is sent to the backend, but the server never replies.
What data or logs do I send to give a hint of what's happening? Do I make a screen recording of the issue?