hey <@U088WCP3B4P>, we're upgrading from elementar...
# ask-elementary-ai
d
hey @kapa.ai, we're upgrading from elementary version 0.15.0 to 0.19.0 but are running in to this error when trying to do the edr source freshness upload. The source file should be newly generated in the same airflow task so wondering if there's something I'm missing to migrate to the new version, any help would be appreciated 🙏
Copy code
edr run-operation upload-source-freshness \
--project-dir . \
--profile-target e2_prod  

    ________                          __
   / ____/ /__  ____ ___  ___  ____  / /_____ ________  __
  / __/ / / _ \/ __ `__ \/ _ \/ __ \/ __/ __ `/ ___/ / / /
 / /___/ /  __/ / / / / /  __/ / / / /_/ /_/ / /  / /_/ /
/_____/_/\___/_/ /_/ /_/\___/_/ /_/\__/\__,_/_/   \__, /
                                                 /____/


Any feedback and suggestions are welcomed! join our community here - <https://bit.ly/slack-elementary>

2025-06-25 15:57:21 — INFO — Running with edr=0.19.0
INFO:elementary.cli.cli:Running with edr=0.19.0
DEBUG:elementary.clients.dbt.command_line_dbt_runner:Running dbt command --log-format json run-operation elementary.log_macro_results --args {"macro_name": "elementary_cli.can_upload_source_freshness", "macro_args": {"invocation_id": "4f5676e9-d7d8-4f67-b1ad-71e4d155acf5"}} --project-dir /Users/david.shi/Library/Caches/pypoetry/virtualenvs/dippr-grznMPux-py3.12/lib/python3.12/site-packages/elementary/monitor/dbt_project --target e2_prod
WARNING:thrift.transport.sslcompat:using legacy validation callback
/Users/david.shi/Library/Caches/pypoetry/virtualenvs/dippr-grznMPux-py3.12/lib/python3.12/site-packages/pydantic/_internal/_config.py:345: UserWarning: Valid config keys have changed in V2:
* 'allow_population_by_field_name' has been renamed to 'populate_by_name'
  warnings.warn(message, UserWarning)
Error: Source freshness for invocation id 4f5676e9-d7d8-4f67-b1ad-71e4d155acf5 were already uploaded.
âś… 1
k
A message from kapa.ai
Based on the error message:
Copy code
Error: Source freshness for invocation id 4f5676e9-d7d8-4f67-b1ad-71e4d155acf5 were already uploaded.
This indicates that Elementary is detecting the source freshness results for this specific invocation ID have already been uploaded. This is a new behavior in recent versions of Elementary, where duplicate uploads for the same invocation are prevented. What could be happening: - The
edr run-operation upload-source-freshness
command is being run more than once with the same invocation ID (which is typically tied to the dbt run or the freshness run). - The
sources.json
file generated by
dbt source freshness
is not being regenerated between runs, so the same invocation ID is reused. - There may be a change in how Elementary tracks or checks for previously uploaded freshness results in version 0.19.0 compared to 0.15.0. What to check and try: 1. Ensure
dbt source freshness
is run immediately before
edr run-operation upload-source-freshness
in the same Airflow task, and that it generates a new
sources.json
file each time. 2. Check for task retries or duplicate executions in Airflow that might cause the upload to be attempted multiple times with the same artifacts. 3. Clear or regenerate the
target/
directory
(where
sources.json
is stored) before running
dbt source freshness
to ensure no stale files are present. 4. Review Airflow logs to confirm that the sequence of commands is as expected and that no previous upload for the same invocation is happening. Unfortunately, the knowledge sources do not contain explicit documentation about this specific error message or changes in invocation ID handling between versions 0.15.0 and 0.19.0. However, similar issues with source freshness uploads and artifact handling have been discussed, especially around ensuring the correct sequence of commands and artifact freshness[Slack thread on source freshness issues](https://slack.com/archives/C02CTC89LAX/p1694700068197439). If after these checks the issue persists, it may be worth reaching out to the Elementary community or support, as this could be a new or edge-case behavior introduced in the latest version. Be sure to provide your Airflow DAG/task sequence and any relevant logs for further troubleshooting.
d
@kapa.ai or if you have any guidance on how invocation id is determined maybe that would help, I could not find too much documentation on how that was generated
k
A message from kapa.ai
The knowledge sources do not provide detailed documentation on exactly how the invocation ID is generated by Elementary or dbt. However, from user discussions and support responses, we know the following: - The invocation ID in the context of Elementary is associated with a specific dbt command execution (such as a run, test, or source freshness command). - For most dbt operations, the invocation ID is unique to each run and is used to track and log the results in Elementary tables. - In the case of source freshness uploads, the invocation ID stored in the dbt_source_freshness_results table is the one from the upload operation itself (i.e., the invocation of edr upload-source-freshness), not the original dbt source freshness run. This has been confirmed by Elementary support: > "the invocation_id is of the invocation who wrote this line to the DWH, meaning the invocation of upload_source_freshness. At the moment we don't save the source freshness invocation id..." [Slack thread on invocation_id in source freshness](https://slack.com/archives/C02CTC89LAX/p1689702183543509) - There is no explicit documentation in the knowledge sources about the algorithm or method used to generate the invocation ID itself (e.g., whether it is a UUID, hash, or other mechanism). If you need to track or debug invocation IDs, you may want to inspect the logs generated by dbt and Elementary, as they often print the invocation ID at the start of each run. If you need more technical details about the generation process, you may need to consult the dbt or Elementary source code, as the knowledge sources do not provide this information.
d
@kapa.ai would you recommend some periodic cleanup of the elementary.dbt_source_freshness_results to minimize collisions of invocation_ids? Just trying to see how we can prevent uploading the same uuid
k
A message from kapa.ai
The knowledge sources do not mention any risk of invocation_id collisions due to the size or retention of the
elementary.dbt_source_freshness_results
table, nor do they recommend periodic cleanup of this table to prevent such collisions. Invocation IDs are intended to be unique per dbt/Elementary run, and collisions should not occur under normal operation. However, there is user interest in retention and pruning of these results for storage management reasons. One user asked about configuring retention or pruning for the *_results tables (including
dbt_source_freshness_results
), but there was no official answer or recommendation provided in the sources about periodic cleanup or its impact on invocation_id uniqueness or collisions. The only mention was a user speculating about the
--days-back
argument, but this was not confirmed as a solution for retention or collision prevention [Slack thread on retention/pruning](https://slack.com/archives/C02CTC89LAX/p1728558831092529). In summary: There is no official guidance in the knowledge sources recommending periodic cleanup of the
dbt_source_freshness_results
table to minimize invocation_id collisions.
If you are concerned about storage or retention, you may consider your own data retention policies, but this is not documented as a method to prevent invocation_id issues. If invocation_id collisions are occurring, it may indicate a different underlying issue with how invocation IDs are generated or reused.
d
would you be able to verify a code snippet to see if the airflow task is properly following the recommendations?
@kapa.ai does anything stand out about how we're executing the upload source freshness in our dag that might look off?
Copy code
dbt_upload_source_freshness_check = BashOperator(
            task_id="dbt_source_freshness",
            bash_command=(
                f"{DBT_INITIAL_CMD} && "
                f"dbt --no-use-colors source freshness --exclude tag:disabled "  # noqa: E231
                f"--profiles-dir {DBT_PROFILE_DIR} "
                f"--profile {DBT_PROFILE} "
                f"--target {DBT_PROD_TARGET} && "
                f"ret=$? && "
                f"edr run-operation upload-source-freshness "
                f"--profiles-dir {DBT_PROFILE_DIR} "
                f"--project-dir {DBT_PROFILE_DIR}{DBT_E2_CODE_BASE} "
                f"--profile-target {DBT_PROD_TARGET} && "
                f"ret=$? && exit $ret"
            ),
            retries=1,
            on_failure_callback=generic_task_error_callback,
            executor_config=k8s_dbt_executor_config,
        )
k
A message from kapa.ai
Based on the knowledge sources, your DAG task for uploading source freshness appears to follow the generally recommended sequence: 1. Run
dbt source freshness
2. Immediately run
edr run-operation upload-source-freshness
in the same BashOperator/task This matches guidance from Elementary support, who have emphasized that both commands should be run in the same task or operator to ensure the
sources.json
file is fresh and available for upload, and to avoid issues with missing or stale artifacts [Slack thread on Airflow and source freshness](https://slack.com/archives/C02CTC89LAX/p1691513076109829) [Another thread on Airflow task sequence](https://slack.com/archives/C02CTC89LAX/p1697013303000359). A few things to double-check based on common issues: - Ensure that the
--project-dir
and
--profiles-dir
arguments are pointing to the correct locations for both dbt and edr commands. Mismatches here have caused issues for other users. - Confirm that the
sources.json
file is being generated in the expected location and is accessible to the
edr
command. - Make sure there are no task retries or duplicate executions that could cause the same invocation ID to be uploaded more than once, as this is a new check in recent Elementary versions. Otherwise, nothing in your command sequence stands out as incorrect based on the available knowledge sources. If you are still encountering the "already uploaded" error, it may be related to how invocation IDs are handled or reused, which is not fully documented in the sources. If the issue persists, consider sharing more detailed logs or reaching out to the Elementary community for further troubleshooting.
g
@David Shi I've actually ran on the same problem, precisely after upgrading from 0.15 to 0.19. We're using github actions, but still, I've cleared the cache and ran everything clean. Did you manage to handle this somehow by clearing some elementary artifacts on target or something? I'm stuck.
d
our solution was disabling the flag
source_freshness_run_project_hooks: False
in our dbt_project.yml. The edr source upload is run automatically after dbt 1.10 as a post run hook, so we were uploading the same results a second time with the same invocation_id which resulted in this error. Hopefully this helps you resolve your issue as well here's the continued thread for context: https://elementary-community.slack.com/archives/C02CTC89LAX/p1751464750864769?thread_ts=1750885014.366019&amp;cid=C02CTC89LAX
g
Oh, I see.. Thank you so much David for the solution and the explanation!