<@U04S8PLJWMT> I have the following returned JSON ...
# ask-ai
r
@kapa.ai I have the following returned JSON I'm working with: `
Copy code
{
  "body": {
    "inventory": [
      {
        "sku": "2619-01",
        "on_hand": 141,
        "available": 141,
        "average_cost": {
          "currency": "usd",
          "amount": 0
        }
      },
      {
        "sku": "8558-01",
        "on_hand": 13669,
        "available": 13667,
        "average_cost": {
          "currency": "usd",
          "amount": 0
        }
      }
    ]
  }
}
I'm using a record selector to get
inventory
and I want to remove the
average_cost
object in the Transformations section. How do I specify the Path because everything I've tried so far doesn't work.
k
To remove the
average_cost
object from each record in the
inventory
array using the Transformations section in Airbyte, you should specify the path as
average_cost
. This is because, after selecting the
inventory
array as your records, each record is an object like:
Copy code
json {   "sku": "2619-01",   "on_hand": 141,   "available": 141,   "average_cost": {     "currency": "usd",     "amount": 0   } }
So, to remove the
average_cost
field from each record, set the transformation path to just
average_cost
. Example configuration in the Transformations section:
Copy code
yaml transformations:   - type: RemoveFields     field_pointers:       - [ "average_cost" ]
This will remove the
average_cost
field from every record in your selected array. If you are using the Connector Builder UI, simply add a "remove" transformation and set the path to
average_cost
(no quotes, no brackets). If you want to remove a nested field, you would use a path like
[ "parent", "child" ]
, but in your case,
average_cost
is a top-level field in each record after selection, so
[ "average_cost" ]
is correct. For reference and more examples, see the documentation on removing fields in transformations: [Transformations - Removing fields](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/record-processing#transformations) and [YAML example](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/record-selector#transformations).
r
@kapa.ai If I do that I get the following error:
dict object' has no attribute 'average_cost
k
A message from kapa.ai
Thank you for your feedback and clarification. Based on the official Airbyte documentation, when you use a record selector to select the
inventory
array, each record processed by transformations is an object inside that array. To remove the
average_cost
field, you should specify the path as
[ "average_cost" ]
in the
field_pointers
of a
RemoveFields
transformation. However, if you are seeing the error
'dict object' has no attribute 'average_cost'
, it suggests that at least one of the records in your data does not have the
average_cost
field. According to the documentation, this should not cause an error—Airbyte is designed to skip missing fields without failing: > During transformation, if a field or any of its parents does not exist in the record, no error is thrown. > [RemoveFields object](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/reference#/definitions/RemoveFields) If you are still encountering this error, it may be due to a bug or a misconfiguration elsewhere. Here are a few things to check: 1. Path Format: The path should be specified as an array:
Copy code
yaml    field_pointers:      - [ "average_cost" ]
or in the UI, just enter
average_cost
as the path. 2. Glob Patterns: If you want to ensure removal even if the field is nested or appears at different levels, you can use glob patterns like
**
(for any level) or
*
(for any field at a level), but for your case,
[ "average_cost" ]
is correct since it's a direct child of each inventory item. 3. Transformation Placement: Make sure the transformation is applied after the record selector, so it operates on each inventory item. If you continue to see the error, it may be an issue with the specific Airbyte version or a bug. The documentation states that missing fields should not cause errors, so this behavior is unexpected based on the official docs. Summary: - The correct path is
[ "average_cost" ]
. - Missing fields should not cause an error according to the docs. - If you still get the error, it may be a bug or version-specific issue. References: - [RemoveFields object](https://docs.airbyte.com/platform/next/connector-development/config-based/understanding-the-yaml-file/reference#/definitions/RemoveFields) - [Transformations in Connector Builder UI](https://docs.airbyte.com/platform/next/connector-development/connector-builder-ui/record-processing#transformations) If you can share your full transformation configuration or more details about your Airbyte version, I can help further troubleshoot.
r
@kapa.ai
[ "average_cost" ]
doesn't work either
k
A message from kapa.ai
Thank you for your patience. Based on the official Airbyte documentation, after using the record selector to select the
inventory
array, each record should be an object with fields like
sku
,
on_hand
,
available
, and
average_cost
. To remove the
average_cost
field, the documented approach is to use a transformation of type
remove
with the path set to
average_cost
(or
[ "average_cost" ]
in YAML) in the Transformations section. This is shown in the documentation examples and should work for your case if the data structure matches what you described [Transformations](https://docs.airbyte.com/platform/1.6/connector-development/connector-builder-ui/record-processing#transformations). However, if specifying
average_cost
or
[ "average_cost" ]
does not work and you receive an error like
'dict object' has no attribute 'average_cost'
, the knowledge sources do not provide an explicit solution or explanation for this behavior. The documentation does not mention this error or provide troubleshooting steps for it. Summary: - The documented method is to use
average_cost
as the path in the remove transformation. - If this does not work and you receive an error, the knowledge sources do not contain enough information to resolve this issue or explain why it is happening. If you continue to encounter this error, it may be a bug or an undocumented limitation. You may want to consult Airbyte community forums or GitHub issues for further assistance, as the official documentation does not address this specific problem.