Skip to content

fix(salesforce): give every exported field the dataType the API requires - #550

Merged
jbonofre merged 1 commit into
apache:mainfrom
RyutoYoda:fix/salesforce-field-datatype-default
Oct 11, 2026
Merged

jbonofre merged 1 commit into
apache:mainfrom
RyutoYoda:fix/salesforce-field-datatype-default

Conversation

@RyutoYoda

Copy link
Copy Markdown
Contributor

Summary

The semantic model API answers a field with no dataType with HTTP 500 and no
indication of which field is at fault:

Internal server error: Creation of semantic entity ... failed. caused by:
Cannot invoke "SemanticFieldDataTypeInternalEnum.name()" because "dataType" is null

Ossie makes datatype optional and marks a field's role with nothing but the
presence of dimension, so a document authored outside Salesforce legitimately
carries fields with no type at all. Export dropped the dataType for those, and
for Time and Opaque, which have no Salesforce equivalent.

Fall back to the one type signal the document still carries, the field's role: a
dimension exports as Text and a measurement as Number. It sits with the
existing displayCategory and label defaults, which run after
custom_extensions are restored, so an exact Salesforce type and an explicit
datatype both still win.

Export is not schema-validated, so this surfaces only on POST, as dataspace and
dataObjectType did in #526.

Verification

  • mvn -B clean verify: 333 tests, 0 failures. main is 331, so this adds two
    and breaks nothing. apache-rat:check clean.
  • Reverting only the main-code change fails exactly those two tests.
  • End to end against a live org, with a model covering every way a dataType can
    go missing: a dimension and a measurement declaring no datatype, a Time
    dimension and an Opaque measurement with no Salesforce mapping, and a
    calculated dimension declaring no datatype. On main the POST is rejected
    500 with the error above and nothing is created. On this branch the same
    model is accepted 201, and the org reads the five fields back as Text,
    Text, Number, Number and Text.

Related Issues

No existing issue covers this.

Checklist

Sections this change does not touch (Specification, Ontology, Validation,
Examples) are omitted rather than left unchecked.

Converters

  • Converter logic updated
  • Tests live under the converter's test directory

Documentation

  • The converter README records the new default and the Time/Opaque change

Tests

  • All existing tests pass: 333 passed locally, green on the CI profile
  • New behaviour is covered by tests that fail without the fix

Compliance

  • ASF license headers present (no new files added)
  • No third-party dependencies added

Ossie makes a field's datatype optional and marks its role with nothing but
the presence of the dimension object, so a document authored outside
Salesforce can legitimately carry fields with no type at all. Export dropped
the dataType for those, and for the portable types Time and Opaque that have
no Salesforce equivalent, and the semantic model API answers a field without
a dataType with HTTP 500 and no indication of which field is at fault.

Fall back to the one type signal the document still carries, the field's
role: a dimension exports as Text and a measurement as Number. The fallback
sits alongside the existing displayCategory and label defaults, which run
after custom_extensions are restored, so an exact Salesforce type and an
explicit datatype both still win.

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks @RyutoYoda!

The role-based default fits the flow well: the putIfAbsent runs after the extension restore and applyOssieDatatype, so exact Salesforce values and explicit mappings still win.

One suggestion (possibly as follow-up): in FieldMappingHandler, a field with an explicit Ossie datatype that has no safe mapping (for example Time or Opaque) and no Salesforce extension now falls through to the role default. It becomes Text, or Number for a measurement, so a Time measurement ships as Number. Before this PR the dataType was omitted and warning said so.
Could we either name the chosen dataType in the warning, or apply the default only when datatype is null?

@RyutoYoda

Copy link
Copy Markdown
Contributor Author

Thanks — taking it as a follow-up, as you suggested. The warning will name the chosen dataType.

On the second option: defaulting only when datatype is null would send Time and Opaque fields to the API with no dataType, which is the HTTP 500 this PR fixes, so I kept the fallback covering them.

@jbonofre
jbonofre merged commit 8b8aed3 into apache:main Oct 11, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants