Skip to content

[FIX] export_bg: Handle import_compat parameter correctly in background export#367

Closed
rov-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-h-109374-rov
Closed

[FIX] export_bg: Handle import_compat parameter correctly in background export#367
rov-adhoc wants to merge 1 commit intoingadhoc:18.0from
adhoc-dev:18.0-h-109374-rov

Conversation

@rov-adhoc
Copy link
Contributor

When import_compat=False, avoid using field 'value' for data extraction to prevent issues when the exported data is used for record updates.

  • In import_compat mode: use name -> value -> id fallback chain
  • In regular export mode: use only name -> id (skip 'value')
  • Field labels (headers) are handled appropriately for each mode

This ensures exported data maintains proper field references based on the intended use case (import vs display/update).

…nd export

When import_compat=False, avoid using field 'value' for data extraction
to prevent issues when the exported data is used for record updates.

- In import_compat mode: use name -> value -> id fallback chain
- In regular export mode: use only name -> id (skip 'value')
- Field labels (headers) are handled appropriately for each mode

This ensures exported data maintains proper field references based on
the intended use case (import vs display/update).
Copilot AI review requested due to automatic review settings February 9, 2026 12:22
@roboadhoc
Copy link

Pull request status dashboard

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Este PR ajusta la exportación en background para que el parámetro import_compat afecte correctamente cómo se derivan los nombres de campos (para extracción de datos) y los headers, evitando usar value cuando la exportación no es import-compatible.

Changes:

  • Se introduce lógica condicional por import_compat para construir field_names y field_labels.
  • En import_compat=True, se usan headers técnicos (compatibles con importación).
  • En import_compat=False, se omite el fallback a value y se mantienen headers “humanos” (label/string).

field_names = [f.get("name") or f.get("value") or f.get("id") for f in params["fields"]]
field_labels = [f.get("label") or f.get("string") for f in params["fields"]]
# Extract field names considering import_compat mode
import_compat = params.get("import_compat", True)
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import_compat está defaulteando a True. Si el front envía import_compat como undefined, JSON.stringify omite la clave y acá se activaría el modo import-compatible por defecto (cambiando headers a técnicos y la extracción). Para evitar regresiones, sería más seguro defaultear a False (comportamiento “export normal”) o normalizar explícitamente el valor (p.ej. bool(params.get('import_compat')) con default False).

Suggested change
import_compat = params.get("import_compat", True)
import_compat = params.get("import_compat", False)

Copilot uses AI. Check for mistakes.
Comment on lines +45 to +51
# For field_names (data extraction), always use the technical field name
# Only use 'value' as fallback when import_compat=True (for import compatibility)
if import_compat:
field_names = [f.get("name") or f.get("value") or f.get("id") for f in params["fields"]]
field_labels = field_names # Use field names as headers for import compatibility
else:
# When not import_compat, use only 'name' or 'id' for field_names, not 'value'
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

El comentario dice “siempre usar el nombre técnico del campo”, pero en el branch import_compat todavía se hace fallback a value/id. Para evitar confusión futura, ajustaría el comentario para reflejar exactamente la cadena de fallback que se está aplicando en cada modo.

Suggested change
# For field_names (data extraction), always use the technical field name
# Only use 'value' as fallback when import_compat=True (for import compatibility)
if import_compat:
field_names = [f.get("name") or f.get("value") or f.get("id") for f in params["fields"]]
field_labels = field_names # Use field names as headers for import compatibility
else:
# When not import_compat, use only 'name' or 'id' for field_names, not 'value'
# Modo import_compat: para field_names usar name -> value -> id,
# y reutilizar esos mismos nombres como cabeceras para mantener compatibilidad de import.
if import_compat:
field_names = [f.get("name") or f.get("value") or f.get("id") for f in params["fields"]]
field_labels = field_names # Use field names as headers for import compatibility
else:
# Modo normal (no import_compat): para field_names usar name -> id
# y para field_labels usar label -> string (etiquetas legibles para el usuario).

Copilot uses AI. Check for mistakes.
@lef-adhoc
Copy link
Contributor

@roboadhoc r+

@roboadhoc
Copy link

@rov-adhoc @lef-adhoc this PR cannot be staged without a bump policy. Please specify either bump or nobump in your comment.

@rov-adhoc
Copy link
Contributor Author

@roboadhoc nobump

roboadhoc pushed a commit that referenced this pull request Feb 9, 2026
…nd export

When import_compat=False, avoid using field 'value' for data extraction
to prevent issues when the exported data is used for record updates.

- In import_compat mode: use name -> value -> id fallback chain
- In regular export mode: use only name -> id (skip 'value')
- Field labels (headers) are handled appropriately for each mode

This ensures exported data maintains proper field references based on
the intended use case (import vs display/update).

closes #367

Signed-off-by: Franco Leyes <lef@adhoc.com.ar>
@roboadhoc
Copy link

Bump policy set to nobump. Modules: all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants