Why a failed job is marked as the latest artifacts?

Hi all,

I have a trouble to obtain the latest artifacts due to the failed job is marked as latest artifacts, even there is no any artifacts. As result, the attempt to download the latest artifact via API gives me 404 error (not found).

the job code:

job_save:
    stage: job
    script:
        - this string generates error
        - Write-Host "Test job $CI_PIPELINE_ID"
        - $CI_PIPELINE_ID | Out-File -FilePath pipeline.id
    artifacts:
        when: on_success
        paths: 
            - pipeline.id
    tags: 
        - windows