<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>60396</bug_id>
          
          <creation_ts>2026-09-04 13:08:25 +0300</creation_ts>
          <short_desc>Ошибка сериализации creator приводит к HTTP 500 при запросе Host API</short_desc>
          <delta_ts>2026-09-04 17:47:27 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>foreman</component>
          <version>unstable</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          <see_also>https://bugzilla.altlinux.org/show_bug.cgi?id=60401</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Vladislav Glinkin">glinkinvd</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>admsasha</cc>
    
    <cc>cas</cc>
    
    <cc>majioa</cc>
    
    <cc>mike</cc>
    
    <cc>nbr</cc>
    
    <cc>pav</cc>
    
    <cc>placeholder</cc>
    
    <cc>rider</cc>
    
    <cc>thatman</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>295397</commentid>
    <comment_count>0</comment_count>
    <who name="Vladislav Glinkin">glinkinvd</who>
    <bug_when>2026-09-04 13:08:25 +0300</bug_when>
    <thetext>Версия пакета: foreman-3.19.1-alt1.2

Предусловия:
Настроенный Foreman. 
С самого же сервера Foreman отправить информацию о системе с помощью: `# puppet agent -t`

Шаги воспроизведения:
1) # curl -k -u admin:password https://$(hostname -f):2345/api/v2/hosts
2) # curl -k -u admin:password https://$(hostname -f):2345/api/v2/hosts/1
3) # curl -k -u admin:password https://$(hostname -f):2345/api/v2/hosts?thin=true
4) В WebUI Foreman перейти на Hosts → All Hosts/Узлы → Все узлы

Фактический результат:
```
# curl -k -u admin:password https://$(hostname -f):2345/api/v2/hosts
{
  &quot;error&quot;: {&quot;message&quot;:&quot;wrong argument type nil (expected String)&quot;}
}
# curl -k -u admin:password https://$(hostname -f):2345/api/v2/hosts/1
{
  &quot;error&quot;: {&quot;message&quot;:&quot;wrong argument type nil (expected String)&quot;}
}
# curl -k -u admin:password https://$(hostname -f):2345/api/v2/hosts?thin=true
{
  &quot;total&quot;: 1,
  &quot;subtotal&quot;: 1,
  &quot;page&quot;: 1,
  &quot;per_page&quot;: 20,
  &quot;search&quot;: null,
  &quot;sort&quot;: {
    &quot;by&quot;: null,
    &quot;order&quot;: null
  },
  &quot;results&quot;: [{&quot;id&quot;:1,&quot;name&quot;:&quot;foreman-test&quot;}]
}

В WebUI на странице с хостами ошибка &quot;Request failed with status code 500&quot;
```

Причина:
Ошибка находится в /usr/lib/foreman/app/views/api/v2/hosts/main.json.rabl

В список сериализуемых атрибутов входят:
```
:creator_id, :creator
```

При этом `creator` является association с `User` и в зависимости от данных возвращает объект `User` либо `nil`, а не гарантированное строковое значение.

Проверенное исправление:
Не передавать association `creator` как обычный attribute:
```
-attributes ..., :creator_id, :creator, ...
+attributes ..., :creator_id, ...
```

и сериализовать его явно:

```
node :creator do |host|
  host.creator&amp;.to_label
end
```

После изменения успешно работают:
```
GET /api/v2/hosts
GET /api/v2/hosts/:id
```

а также страница Host в Web UI.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>295482</commentid>
    <comment_count>1</comment_count>
    <who name="Vladislav Glinkin">glinkinvd</who>
    <bug_when>2026-09-04 17:47:27 +0300</bug_when>
    <thetext>Дальнейшее тестирование показало, что проблема связана с &quot;Deprecate aliasing non-attributes with alias_attribute&quot;.

https://guides.rubyonrails.org/7_1_release_notes.html#active-record-deprecations</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>