<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[iRedMail — RESTful API spam_score parameter rejects decimal values (e.g. 4.5)]]></title>
	<link rel="self" href="https://forum.iredmail.org/feed-atom-topic21197.xml" />
	<updated>2026-08-13T11:11:09Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.iredmail.org/topic21197-restful-api-spamscore-parameter-rejects-decimal-values-eg-45.html</id>
		<entry>
			<title type="html"><![CDATA[RESTful API spam_score parameter rejects decimal values (e.g. 4.5)]]></title>
			<link rel="alternate" href="https://forum.iredmail.org/post92171.html#p92171" />
			<content type="html"><![CDATA[<p>==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====<br />- iRedMail version (check /etc/iredmail-release):&nbsp; 1.6.0<br />- Deployed with iRedMail Easy or the downloadable installer? downloadable installer<br />- Linux/BSD distribution name and version:&nbsp; Almalinux 8<br />- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL<br />- Web server (Apache or Nginx): nginx<br />- Manage mail accounts with iRedAdmin-Pro? yes<br />- [IMPORTANT] Related original log or error message is required if you&#039;re experiencing an issue.<br />====</p><p>Hi,<br />I&#039;m trying to set a fractional spam score via the RESTful API (PUT /api/spampolicy/user/&lt;mail&gt;, same for domain and global), e.g.:<br />spam_score=4.5<br />According to the docs docs.iredmail.org/iredadmin-pro.restful.api.html#spam-policy , the spam_score parameter is described just as &quot;spam score&quot;, with the sample using an integer (spam_score=4), but it&#039;s not explicitly stated that decimals are disallowed.</p><p>I checked the source and found the relevant code in libs/amavisd/spampolicy.py.</p><p>str.isdigit() returns False for any string containing a decimal point, so spam_score=4.5 silently fails the if check — the block is skipped entirely, no error is returned, and spam_tag2_level/spam_kill_level are simply left unset. The API still responds with {&quot;_success&quot;: true}, which is misleading since the value wasn&#039;t actually applied.</p><p>Interestingly, the code itself calls float(v) right after the isdigit() check, which suggests decimal support was intended but blocked by the wrong guard condition (should probably be a try/except around float(v) directly, rather than isdigit()).</p><p>Questions:</p><p>1. Is integer-only spam_score an intentional limitation, or is this a bug in the input validation?<br />2. Through the iRedAdmin-Pro web GUI, decimal spam score values are accepted and correctly applied/stored — so this inconsistency seems specific to the RESTful API input handling. Can you confirm the API is meant to behave the same way as the GUI here?<br />3. If it&#039;s a bug, could it be fixed in an upcoming release? Happy to test a patch if provided.</p>]]></content>
			<author>
				<name><![CDATA[msitarz90]]></name>
				<uri>https://forum.iredmail.org/user160725.html</uri>
			</author>
			<updated>2026-08-13T11:11:09Z</updated>
			<id>https://forum.iredmail.org/post92171.html#p92171</id>
		</entry>
</feed>
